I am trying to generate an admin page, which lists all the records in a table and allows the admin to make changes to the text fields, and write it back to the db. It starts like this:
<form method = "POST" action="admin_vieworders.php">
<table width="100%" cellpadding="2">
<?php
$row_count = 0;
$result = mysql_query("SELECT * FROM dd_order ORDER BY id DESC");
while ( $row = mysql_fetch_array($result) ) {
//display rows....
echo("<tr bgcolor='$color2'><td><b>Client: </b></td><td>" . "<INPUT TYPE='TEXT' NAME='client' size='40' maxlength='100' VALUE=" . $row["client"] . "></td></tr>
etc....
...which just gets the data and dumps it into repeating table rows. After it lays out the rows for each record, I put an "Update" button, like this:
<tr><td><input type='button' name = 'update" . $row_count . "' value='Update'></td></tr>");
$row_count++;
//update/delete functions
if (isset($update))
{
$query = "UPDATE dd_order SET client='$client', order_date='$order_date', duedate='$duedate', image='$image', quantity='$quantity', size ='$size', priceper = '$priceper', total='$total', status='$status', notes='$notes' WHERE id = $id";
$result = mysql_query($query);
check_mysql();
$message = "Record Updated (id=$id)";
}
...so each "Update" button is generated with a number set by "$row_count", i.e. "button0", "button1", etc.
So basically, I get a page with each record in the table displayed, with a button after each record that should update the db with any changes I make.
But of course, it's not working. 🙁
Does not update the db. I know it's a long shot, but does anyone see where I'm going wrong?