Page 1 of 1

How to pass column data through form button?

Posted: Wed Feb 11, 2004 12:19 pm
by toothpick
Sorry for the possibly confusing subject, here's what I'm trying to do. I've made a form that uses this while loop to go through each row in a mysql table and displays the data in a table.

Code: Select all

while($row=mysql_fetch_array($query))
{

echo "
<td>$row&#1111;custNo]</td>
<td>$row&#1111;fName]</td>
<td>$row&#1111;lName]</td>
<td>$row&#1111;address]</td>
<td>$row&#1111;city]</td>
<td>$row&#1111;state]</td>
<td>$row&#1111;zip]</td>
<td>$row&#1111;phone]</td>
<td><FORM METHOD='post' ACTION='delete.php'>
<INPUT TYPE='SUBMIT' VALUE='Delete'></FORM></td>

</tr>";
&#125;
As you can see, each row has it's own Delete button (using Submit to go to delete.php). What I am trying to figure out, is how to send the ID(custNo in my example) that the row that the clicked Delete button is on to delete.php so I can display that row data and confirm the delete.

Thanks in advance for any help.

Posted: Wed Feb 11, 2004 1:26 pm
by qads
you are useing a form, why not just add a hidden field with ID as the value? :?

Code: Select all

<input type="hidden" name="id" value="id_here">

Posted: Wed Feb 11, 2004 3:25 pm
by toothpick
Good point, I had a bit of a brainfart there. I also found out this way to do it:

I replaced

Code: Select all

<td><FORM METHOD='post' ACTION='delete.php'>
with

Code: Select all

<td><FORM METHOD='post' ACTION='delete.php?id=".$row&#1111;'custNo']."'>
That gets it done. Thanks

Posted: Thu Feb 12, 2004 1:05 pm
by qads
hm..ur passing the id in GET, i dont see a need for the form there, you can pass it with a link too :P