okay, i'm trying to make a form that i can use to change quantities for
items in a database that has one table with these columns:
rec_id = auto increment primary key
brand = varchar
description = varchar
category = varchar
sub_category = varchar
quantity = int
I have a drop down that sorts
all items by category included in the main page. That form creates a table on a new page that displays the item, current quantity and a field for inputting the new quantity done like so:
CODE
<form action= "test.php" method= "post">
<table>
<tr>
<th>brand</th>
<th>item</th>
<th>sub_category</th>
<th>color</th>
<th>present quantity</th>
</tr>
<?php
// Print out the contents of each row into a table
while($row = mysql_fetch_array($result)){
echo "<tr>" ;
echo "<td>" . $row['brand'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $row['sub_category']. "</td>";
echo "<td>" . $row['color'] . "</td>";
echo "<td>" . $row['quantity'] . "</td>";
echo "<td><input type= text name= " . $row['rec_id'] . "[]></td>";
echo "</tr>" ;
}
?>
</table>
<input type= "submit" name= "test" value= "submit" >
</form>
This returns a table that has an input field for each item listed. I need
to be able to put a quantity in any number of those fields, and have it
update the quantity in the database. I also need it to leave blank fields
alone. So, my query on the page that is supposed to process that form
looks like this:
CODE
$query = "UPDATE quantity SET items.quantity = '$quantity' WHERE
items.rec_id = '$rec_id'";
This works for one of the rows if i set $rec_id = $_POST['whatever'] and
$quantity = $_POST['whatever']
I can't figure out how to:
$quantity = the number I entered in the row
$rec_id = the primary key associated with that row
I tried to include pertinent info without extraneous info, so let me know
if this makes any sense.
I really would apprieciate your help on this, it's had me stumped for a
couple of days.