Count Image Views
I have a simple image rotation recordset for an advert image or banner:
<?php
$rsAdverts = new WA_MySQLi_RS("rsAdverts",$mysqli2,1);
$rsAdverts->setQuery("SELECT * FROM adverts ORDER BY RAND ()");
$rsAdverts->execute();
?>
In the DB table I have a INT column for "advert_views" which needs to be updated each time an image is displayed.
I would like to count the number of views for a particular image and incrementally update the "advert_views" column in the "adverts" table so that I can display this number..
Can this be done in the recordset or do I need to have some "trigger" on the page in the PHP code that displays the image that updates the table? Or both?
Update:
I tried this recordset but it causes a MYSQL error:
<?php
$rsAdverts = new WA_MySQLi_RS("rsAdverts",$mysqli2,1);
$rsAdverts->setQuery("SELECT * FROM adverts ORDER BY RAND () UPDATE adverts.advert_views SET adverts.advert_views = adverts.advert_views + 1");
$rsAdverts->execute();
?>
Thanks