Hi guys,
Doing a small project and i'm pretty new to php/mysql so hoping someone can help.
Basically...
I have a form with a table in it with the fields (id, model, current stock level, new stock level)
The table is populated using a mysql query to get the data from 1 table in a database.
In the new stock column there's a simple blank text box to put a number in.
so for example the page might look:
(ID) (Model) (current stock level) (new stock level)
1 AAA 3 [ ]
2 BBB 1 [4]
3 CCC 4 [ ]
4 DDD 4 [2]
5 EEE 5 [ ]
[SUBMIT BUTTON]
so when i click the submit button it updates the rows with id 2 and 4 with replace the current stock levels with the value in the new stock level.
but the week after the same page might look like this:
(ID) (Model) (current stock level) (new stock level)
4 DDD 3 [1]
6 FFF 1 [ ]
7 GGG 4 [ ]
8 HHH 4 [ ]
9 III 5 [2]
11 GHF 4 [ ]
13 DFE 4 [3]
[SUBMIT BUTTON]
so when i click the submit button this time it updates the rows with id 4, 9 and 13 with the values, each time ignoring the rows with dont have anything entered in the new stock level column
Basically i know how to do it if it was just the one record, but how do i get it to update all the ones with numbers in the new stock level column at the same time, and ignore it if it doesn't have anything entered in the text box?
the code for my form is:
<?php
$query = "SELECT * FROM items";
$result = doQuery($query);
if($result==false) {
echo mysql_error();
} else {
$rowcount = 1;
while($row=mysql_fetch_assoc($result)) {
echo "<tr>";
echo "<td style=\"text-align: center;\">".$row['item_id']."</td>";
echo "<td style=\"text-align: center;\">".$row['item_model']."</td>";
echo "<td style=\"text-align: center;\">".$row['cart_colour']."</td>";
if ($row['item_stock']=="2")
echo "<td style=\"text-align: center;\"><font color =\"#d50031\">"."<b>".$row['cart_stock']."</b>"."</font></td>";
elseif ($row['item_stock']=="1")
echo "<td style=\"text-align: center;\"><font color =\"#d50031\">"."<b>".$row['cart_stock']."</b>"."</font></td>";
elseif ($row['item_stock']=="0")
echo "<td style=\"text-align: center;\"><font color =\"#d50031\">"."<b>"."Out Of Stock :("."</b>"."</font></td>";
else
echo "<td style=\"text-align: center;\"><font color =\"#009933\">"."<b>".$row['cart_stock']."</b>"."</font></td>";
?>
<form class="cmxform" id="signupForm" method="post" action="../../php/test123.php">
<td style="text-align: center;">
<input type="hidden" name="cart_id" value="<?php echo $row['item_id']?>">
<input type="text" name="item_new_stock_total" style="width:20px">
</td>
<?php
echo "</tr>";
$rowcount++;
}
}
?>
appreciate any help!
thanks!