View Single Post
  #1 (permalink)  
Old Feb 2nd, 2008, 21:14
Jack Franklin's Avatar
Jack Franklin Jack Franklin is offline
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,310
Blog Entries: 8
Thanks: 10
Thanked 5 Times in 5 Posts
Adding a column to a table

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,
__________________
Resources Administrator


Reply With Quote