Auction item hit counter

A place to discuss and receive support for the Web Auction application.

Postby 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
bwilson
 
Posts: 10
Joined: Wed Dec 31, 1969 5:00 pm

Postby 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).
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Web Auction Discussion

Who is online

Users browsing this forum: No registered users and 27 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved