I have two php pages and I’d like to check which button is
checked in the fist one so be able to use its value in the next php
page.The problem is that the submit button is into a while loop so I
can’t use different values, may it can be using an i variable but I
don’t know how. form of the first page is:
<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>
in the next page, php code is like:
<?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
?>
If you want to pass a value over to your new form, insert the value into a hidden form element:
So that in your next page, you can access this value using:
P.S. You really need to change the way you’re accessing your data. Access the data first, preferably using an external class, and then use the data in your rendered output. Don’t mix HTML and PHP data logic as if they’re best buds.