Auction item hit counter
Archived from the Web Auction Discussion forum.
bwilson — Tue Sep 25, 2007 8:41 am
Would it be difficult to add a hit counter for each auction item?
Would it be as simple as adding a “count” field to the products table and then adding some code to the view_product.html file?
I’m new to php/mySql.
Bob
shannah — Tue Sep 25, 2007 9:38 am
Yup.. that’s pretty much all it would take.
The code in view_product.html might look something like:
- Code: Select all
{php} $app =& Dataface_Application::getInstance(); $product =& $app->getRecord(); if ( $product ){ mysql_query("update products set `count` = `count`+1 where product_id='".addslashes($record->val('product_id'))."'", df_db()); } {/php}
assuming that you added a field named ‘count’ to the products table.
Note that this won’t work properly if you are using the dataface output cache (which is disabled by default).