我有两个 php 页面,我想检查第一个中哪个按钮被选中,以便能够在下一个 php 页面中使用它的值。问题是提交按钮进入了一个 while 循环,所以我不能使用不同的值,可能它可以使用一个i
变量,但我不知道如何。第一页的形式是:
<form name="myForm" action="admin.php" method="post">
<table BORDER=1....... > <?php $link = mysql_connect('localhost', 'root', ''); if
(!$link) {
die('Could not connect: ' . mysql_error()); }
mysql_select_db("nowdeal");
$query = mysql_query("SELECT * FROM application ORDER BY date");
WHILE($rows = mysql_fetch_array($query)):
$date = $rows['date'];
$username = $rows['username'];
$advers = $rows['advers'];
$id = $rows['id'];
echo '<tr>';
echo "$date";
echo "</br>";
echo "$username";
echo "</br>";
echo "$advers";
echo "</br>";
echo "$address";
echo "</td>";
echo '<td align="left">';
echo '<input type="submit" name="action" value="edit" />';
$_SESSION["id"]=$id;
echo '</td>';
echo '</tr>';
endwhile; ?> </table> </form>
在下一页中,php 代码如下:
<?php session_start();
$con = mysql_connect("localhost","root",""); if (!$con) {
die('Could not connect: ' . mysql_error()); }
mysql_select_db("nowdeal", $con);
mysql_query("SET names 'utf8'");
if(isset($_POST['paid']))
{ if($_POST['paid']=="yes") ///is a value from a drop down list
{mysql_query("UPDATE application SET paid='yes' WHERE .....");}
///i want to be like : WHERE id=session[id], but when it works it
takes only //the last id ,so be upadated the last row only
?>