[英]php get value of submit button when value is a variable
I tried to search but was unable to find an answer for this question. 我试图搜索,但找不到此问题的答案。
I am trying to get the value of the button in my submit button that is a variable. 我试图在我的提交按钮中获取按钮的值,该值是一个变量。
CODE is as follows 代码如下
$penrequest = "select * from request where status='pending';";
$penreg = mysql_query($penrequest);
echo "<form method='post' action=''>";
while ($row = mysql_fetch_array($peneg))
{
echo "<input type='submit' name='answer' value='$appdeny'>";
}
if (isset($_POST['answer']))
{
echo $appdeny;
}
Ok the code works...if you hit the button its caught by the if statement like its supposedt o be. 好的代码可以工作...如果您按下按钮,它就会被if语句所捕获,就像它本来应该是的那样。 the variable $appdeny is a messageID number filled from a mysql database which can change.
变量$ appdeny是从mysql数据库填充的messageID号,可以更改。 When the user clicks a button i want to print the messageID of the number displayed as the value of the answer button.
当用户单击按钮时,我要打印显示为数字的messageID作为应答按钮的值。
Change: 更改:
echo "<input type='submit' name='answer' value='$appdeny'>";
to: 至:
echo "<input type='submit' name='answer' value='" . $row['appdeny'] . "'>";
Change: 更改:
echo $appdeny;
to: 至:
echo $_POST['answer'];
You also need to do: 您还需要执行以下操作:
echo "</form>";
after the while
loop. 在
while
循环之后。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.