I have a table which consists of 20 items. each row also has a dropdown menu so i can change the price of these items. These dropdown menus all have the name of the position which it appears in the table. so for example the dropdown menu which is 4th in the table will have the name = 4. Im trying to work out how i can build script which will only submit the variables where there has been a change in the price.
At the moment i am using the foreach function. This works but it submits all the variables even if their hasnt been a change which means my date & name field has a date & name where there hasnt been a change in the price, and this is something i do not want.
so information which gets submitted is:
name=Jermz&1=5&2=0&3=0&4=0&5=0
i would prefer if the only data changed would be submitted:
name=Jermz&1=5
Here is the coding i am using at the moment.
foreach ($_REQUEST as $id = $rating){
$update_table = sprintf("UPDATE items SET price = price + %s, name = %s, date = %s, WHERE item_id = %s",
quote_smart ($price),
quote_smart ($name),
quote_smart ($date),
quote_smart ($id));
$result = mysql_query($update_table) or die ("ERROR".mysql_error());
This has the desired effect but the foreach function submits all the variables meaning all the items in table are displyed with the same name, when the person wasnt intending to update all the items.
Please Help!!!