Hello
I'm attempting to design an online program for my employers for company use. I'm sure it's not that hard to do but I am stuck.
Basics of script...
I make a simple query to mySQL database and end up with a few rows of data outputted with a couple of fields formatted as text boxes waiting for input to update the table.
So far so good. At the end of each row of data I have a a submit button. What I want to do is to be able to update each row individually (with the option of updating all rows at once).
The way it's working now only the data in the last row is being used to update and is updating all fields in the database globally. I am unable, as yet, to find a way to work with each individually.
I suspect I need a way to give each text box a unique name that the next (update) SQL statement understands. I tried using $n1, which is unique to each row, as the name but it doesn't work.
Thank you.
Relevant code follows...
SQL involved...
$sql = "select zone, DATE_LAST_VISITED, ZONE_DESCRIPTION, CURRENT_STATUS from WESTERN_WASHINGTON where current_status = 'off' ORDER BY date_last_visited ASC";
..................................
// start results formatting
echo "<form action='http://127.0.0.1/php101/racks/assign.php'>";
echo"<table border= 1 align= CENTER WIDTH=550 >";
echo"<tr><form><th> Zone </th><th> Date Last Visited </th><th> Zone Description</th><th>Current Status</th><th>Truck #</th><th>Driver</th>";
while ($row = mysql_fetch_array($sql_result)) {
$n1 = $row["zone"];
$n2 = $row["DATE_LAST_VISITED"];
$n3 = $row["ZONE_DESCRIPTION"];
$n4 = $row["CURRENT_STATUS"];
$n5 = $row["truck_no"];
$n6 = $row["driver"];
echo "<tr>
<td>$n1</td>
<td>$n2</td>
<td>$n3</td>
<td>$n4</td>
<td><input type='text' size='7' name='truck'></td>
<td><input type='text' name='driver'><input type='submit' value='Assign Zone'></td>
</tr>";
}
echo"</table></form>";
next script SQL...
$sql = "update WESTERN_WASHINGTON set truck_no = '?', driver = '?' where zone = '?'";