Hi, I'm very very new to MySQL. I have created a table to hold my inventory. Products - Color - Size - Quantity.
<?
$self = $_SERVER['PHP_SELF'];
$productid = $_POST['productid'];
$product = $_POST['product'];
$productsize = $_POST['productsize'];
$productcolor = $_POST['productcolor'];
$productquantity = $_POST['productquantity'];
$conn = @mysql_connect("localhost", "root", "password")
or die("Err: Could not connect to mysql");
$rs = @mysql_select_db(inventory, $conn) or die("err: Can't connect to DB");
$sql="select product, productsize, productcolor, productquantity from Products order by product, productcolor";
$rs = mysql_query( $sql, $conn );
echo("<form action\"" . $self . "\" method=\"post\"><table>");
while( $row =mysql_fetch_array($rs) )
{
echo("<tr><td>" . $row["product"] . "</td>" );
echo("<td>" . $row["productcolor"] ."</td><td>" . $row["productsize"] ."</td><td>" . $row["productquantity"] . "</td></tr><br>");
}
echo("</table><input type=\"submit\"></form>");
?>
It works fine, but I'm having trouble figuring out how to edit the quantity. My idea was to have the number display in an input field (I can handle that) but I really don't understand how to update the data when I change it. I think that I need to use - $sql = 'UPDATE Products SET productquantity = \'mynewnumber\' - but I don't know how, or where? Could someone give me an idea on where to go from here? Thanks.