Jump to content

[SOLVED] UPDATE function query


e1seix

Recommended Posts

$p1=$row[pop];
$p2=1;
$pop=($p1+$p2);

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

 

what's wrong with this code?

 

the idea is that when a page loads on my website with the corresponding sku, the corresponding SET "pop" gets updated by 1

 

ie. the point is to show me which of my product sku's is most viewed by clients so i can base a top selling products page on. i did post this earlier today and now i can't find the topic at all to rehash it.

 

anyway, any help would be appreciated. I'm more familiar with SELECT as oposed to UPDATE.

 

what i have initially works and updates all products with "0" views to "1", but if the same page is revisited or refreshed it stays at "1".

 

many thanks,

Link to comment
Share on other sites

You can add in the query itself and use single quote around $sku

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

 

i'm guessing the additional " is out of place but even with taking that out i'm getting a t_string error

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.