Web Hosting Talk







View Full Version : Help! How can I track database queries?


rotis
09-11-2008, 04:50 PM
I have a simple site that is based on one mysql table. How can I track the data so I can post a simple "most popular content" block?

I will gladly settle for a referral to a tutorial.

osphere
09-11-2008, 10:32 PM
Mmmmm I would add a row, that counts how many times its requested, and when a page is loaded from the table, just update that entry adding 1

JBapt
09-12-2008, 02:45 AM
Mmmmm I would add a row, that counts how many times its requested, and when a page is loaded from the table, just update that entry adding 1

If you don't have a lot of queries on that database that sounds fine.

rotis
09-17-2008, 10:37 AM
If you don't have a lot of queries on that database that sounds fine.
2 questions,

How do i do that? and what if i did have a lot of queries?

Codebird
09-17-2008, 04:13 PM
I would add a column to that table called count_requests and then every time that content is requested let's say it is content with id 5

I execute this query


mysql_query("UPDATE the_table SET count_requests=count_requests+1 WHERE id='5'");

it wouldn't affect a lot even if there is so much queries