Web Design and Development Forums

Adding a column to a table

This is a discussion on "Adding a column to a table" within the MySQL section. This forum, and the thread "Adding a column to a table are both part of the Databases category.


Go Back   Webforumz.com > Databases > MySQL

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old Feb 2nd, 2008, 21:14   #1 (permalink)
Section Manager - WOTM
Assistant Editor - LZ
 
Jack Franklin's Avatar
 
Join Date: May 2007
Location: Cornwall, England
Posts: 1,101
Blog Entries: 5
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,
__________________
Section Manager (WOTM)

My Weblog & E-Portfolio
Catch me daily on: Twitter | Digg | Flickr
Jack Franklin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Feb 2nd, 2008, 21:21   #2 (permalink)
 
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,749
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: Adding a column to a table

Yeah... here is some code:

Code: Select all
mysql_query("ALTER TABLE `articles` ADD `column` VARCHAR(255) NOT NULL;")
__________________
I'm back!!!!
Marc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Feb 3rd, 2008, 08:17   #3 (permalink)
Section Manager - WOTM
Assistant Editor - LZ
 
Jack Franklin's Avatar
 
Join Date: May 2007
Location: Cornwall, England
Posts: 1,101
Blog Entries: 5
Re: Adding a column to a table

Brilliant thanks Mark
__________________
Section Manager (WOTM)

My Weblog & E-Portfolio
Catch me daily on: Twitter | Digg | Flickr

Last edited by Jack Franklin; Feb 3rd, 2008 at 08:19.
Jack Franklin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding 1 to Column Value Jack Franklin PHP Forum 4 Feb 3rd, 2008 10:19
How to automatically 'add column' to table? skuliaxe MySQL 1 Jan 22nd, 2008 10:40
Sorting A Table By Column Header NewDesigner MySQL 4 Dec 8th, 2006 01:53
SQL Syntax for adding multiple rows together from 1 column jfergy MySQL 3 Jan 17th, 2006 04:12
..copy data from column A in Table A to column B in Table B? gecastill MSSQL & Access 10 Jun 23rd, 2005 18:27



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 17:27.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59