Jump to content

the UPDATE function


e1seix

Recommended Posts

I have a bit of a question. It's more or less to see if this is possible. I have only ever really used the SELECT function of PHP.

 

I have a large product site and I'm trying to think of a way to log the pages on my site that get the most clicks. Yes, I could technically use my host to do this but I'm wondering if you think this is feasbible.

 

Aswell as productName, productDescription, productPrice etc. in mySQL if I had another tag (I'm terrible with terminology!) called "popularity" and if I could somehow use the UPDATE function, so that every time a particular product page was loaded it would update its corresponding "popularity" value by 1, I could then go into phpAdmin and view which products had the highest "popularity" value and also use ORDER BY popularity to display what products were currently front runners in a top sellers page...

 

Would that work in peoples' opinions? And what way would you go about using the UPDATE function to do this... an 'if' statement?

Link to comment
https://forums.phpfreaks.com/topic/75892-the-update-function/
Share on other sites

$pop=$row[pop];
$p=1;
$popp=($pop+$p);

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

 

OK so i have gotten this far as yes - it appears to work, but only once. ie. it has updated the pages pages i have looked at to "1" instead of "0." but it won't load any of the "1's" to "2's" if i go refresh the page.

 

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/75892-the-update-function/#findComment-384106
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.