-
1. Re: PHP/MySQL Page counter
matthew stuart Jan 31, 2013 4:35 AM (in response to matthew stuart)Doesn't anybody have any idea of how I might attack this?
How do I submit to the database that a record has been viewed and increment it by 1?
If this was a form, I am sure I could do it as I am able to insert and update records within a DB, but as there is no form involved in this, I have no idea how to attack it and make it count from 0 to 1 to 2 and so on...
Thanks
-
2. Re: PHP/MySQL Page counter
bregent Jan 31, 2013 5:43 PM (in response to matthew stuart)If someone is viewing a record then there would be a related SELECT statement. Right after the SELECT statement, just issue an UPDATE statement against the same record that increments the field by 1.
-
3. Re: PHP/MySQL Page counter
matthew stuart Feb 1, 2013 4:35 AM (in response to bregent)OK. I understand the concept behind that, and I can see it would work for me.
How do I trigger the update statement though? I'm only aware of being able to update a record by clicking a form button.
-
4. Re: PHP/MySQL Page counter
matthew stuart Feb 1, 2013 4:55 AM (in response to matthew stuart)Just found this on tinternet...
mysql_query("UPDATE counter SET counter = counter + 1");
I assume 'counter' is the name of the column with the DB table, and that as soon as the page is loaded it will automatically update the appropriate record. Is that right?
Thanks.
-
5. Re: PHP/MySQL Page counter
bregent Feb 5, 2013 1:28 PM (in response to matthew stuart)Yes, that is correct.



