e1seix Posted November 3, 2007 Share Posted November 3, 2007 $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, Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 3, 2007 Share Posted November 3, 2007 You can add in the query itself and use single quote around $sku mysql_query("UPDATE fragrances SET pop=pop+1" WHERE sku='$sku'") Quote Link to comment Share on other sites More sharing options...
e1seix Posted November 3, 2007 Author Share Posted November 3, 2007 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 Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 3, 2007 Share Posted November 3, 2007 Yep I had an extra double quote in there sorry <?php mysql_query("UPDATE fragrances SET pop=pop+1 WHERE sku='$sku'") ?> Quote Link to comment Share on other sites More sharing options...
e1seix Posted November 3, 2007 Author Share Posted November 3, 2007 Yep I had an extra double quote in there sorry <?php mysql_query("UPDATE fragrances SET pop=pop+1 WHERE sku='$sku'") ?> it gives me a t_variable error. any ideas...? Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 3, 2007 Share Posted November 3, 2007 Are you adding the ending semi colon -> ; Quote Link to comment Share on other sites More sharing options...
e1seix Posted November 3, 2007 Author Share Posted November 3, 2007 i am now and... it works. many thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.