View Full Version : UPDATE query

11-03-2007, 10:47 AM

mysql_query("UPDATE fragrances SET pop = '$popp'
WHERE sku=$sku");

i'm a bit unfamiliar with the UPDATE function as opposed to the SELECT one, so i'm stumped as to why this isn't working.

the idea behind this code is that when the page is loaded, it automatically updates the set of "pop" by 1. this works fine the first time ie. from "0" to "1".

but now when i refresh a page or go back at a later date the pages that have the pop value of "1" aren't moving up to "2".

i'm stumped! any ideas?

11-03-2007, 11:31 PM
$pop=(int) $row['pop'];

mysql_query("UPDATE `fragrances` SET `pop` = '$popp' WHERE `sku`='$sku'");

11-03-2007, 11:37 PM
mysql_query('update fragrances set pop = pop + 1 where sku = ' . $sku);

11-20-2007, 09:22 AM
Another way is to simply...

mysql_query("UPDATE `fragrances` SET `pop` = `pop`+1 WHERE `sku`='$sku'");

11-20-2007, 09:24 AM
Same code.

11-20-2007, 09:28 AM
I didn't scroll down far enough to read the rest of the posts... :)