On my blog I have a large table with all my posts stored in with various columns: title, date, category, etc. My plan is to add a column called 'Views', and then whenever someone views that post, get the
PHP to add one to the value of 'Views'. Then on my sidebar I can display the most popular posts.
So, is there a way of adding a column to a table?
And, will my idea of adding 1 to the views column work, and how would I do it? I'm guessing it would be more
PHP.
- PHP: Select all
$views = ("SELECT views FROM content WHERE contentid='$contentid'");
while ($no_views = mysql_fetch_array($views)) {
$views_before = $no_views['views'];
$views_after = $views_before + 1;
}
Is that the right code for it or not?
(Mod, you can move to
PHP forum if you like,