Atempting to update database table


I am a complete newcomer to php/mysql and am trying to learn it by creating a small project. I am developing the first page, which I thought would be the easiest, but I have hit a wall.

I am attempting to list out two columns from a database, inventory and the price of the inventory. what I would like to do is have the ability to change the prices of the inventory if needed and then update the database with the new prices.

I have done some searching and found some code that is simular to my needs and tried to adapt it to my situation. At this point, I can see my listing, change the price on the page, but when I submit the changes, the DB is not updated. Any help would be greatly appreciative.

Here is what I got now.


<?php include '../../include/config.php'; $query = mysql_query("Select * from Prices"); // Count table rows $count=mysql_num_rows($query); ?>
<?php while($rows=mysql_fetch_array($query)){ ?> <? $id[]=$rows['id']; ?> <?php } ?>
Name Price
<? echo $rows['name']; ?>
<?php // Check if button name "Submit" is active, do this if($Submit){ for($i=0;$i<$count;$i++){ $sql1="UPDATE Prices SET price='$price[$i]' WHERE id='$id[$i]'"; $result1=mysql_query($sql1); } } if($result1){ header("location:update.php"); } mysql_close(); ?>


Sponsor our Newsletter | Privacy Policy | Terms of Service