Forum Moderators: coopster
<form method="POST" action="change_form.php">
<input type="hidden" name="id" value="<? echo $id;?>">
<input type="submit" value="EDIT">
</pre>
</form>
Why doesn't this work? Why can't you use the id as a variable?
This is what works at the bottom of the table (but proves to be a hassle):
<form method="POST" action="change_form.php">
<pre>
Enter Line Number to Edit: <input type="text" name="id" size="5">
<input type="submit" value="Submit">
</pre>
</form>
As for your question: you can ofcourse use $id in the way you did. It will need to be created first and filled with data. Maybe you could provide some more information about how you're doing that.
[edit: forget about the URL-thing; it's allready gone ;)]
The code loops through all the returned rows from the table yourTABLE. I suggest you limit your SELECT statement.
<?php
mysql_connect( 'www.yourdomain.com', 'yourDBUSER', 'yourDBpassword' ) or die ( mysql_error() );
mysql_select_db( 'yourDB' ) or die ( mysql_error() );
$sql = "SELECT * FROM yourTABLE";
$result = mysql_query( $sql ) or die ( mysql_error() );
while ($row = mysql_fetch_array ($result))
{
?>
<form method="POST" action="change_form.php">
<input type="hidden" name="id" value="<?php echo $row[id];?>">
<input type="submit" value="EDIT">
</pre>
</form>
<?php }?>
Does this answer your question?
Before anyone jumps down my throat... this is simply a sceleton to start from)