I generated a form from a db, and want to use the selected value on a subsequent page, but cant fugure out how to pass it. What's the easiest way?
Code: Select all
echo "<table border='0' cellpadding='4px' style='border-color:#FFF'>";
$query = "SELECT * FROM users ORDER BY admin ";
$result = mysql_query($query, $connection);
$num=mysql_num_rows($result);
$i=0;
echo "<form action='go_to_user.php' method='post'>";
echo "<table>";
while ($i < $num){
$row = mysql_fetch_array($result);
echo '<tr>';
echo '<td>'.$row['display_name'].'</td>';
echo '<td> <input type="radio" name="user" value="'.$row['display_name'].'" /></td>';
echo '<td><input type="submit" name="submit" class="btn" value="Edit User" /></td></tr>';
$i++;
}
echo "</table></form>Code: Select all
if (isset($_POST['submit']))
{ // Form has been submitted.
$user = trim(mysql_prep($_POST['user']));
}