Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-26-2012, 02:47 PM   PM User | #1
KazeFlame
New Coder

 
Join Date: Sep 2012
Location: Philippines
Posts: 11
Thanks: 9
Thanked 0 Times in 0 Posts
KazeFlame is an unknown quantity at this point
Question How to add integer to a column?

Hello guys! Please teach me how to add an integer to a column.

Here is my code but it doesn't work.
PHP Code:
$sql "UPDATE `flashgames`.`flashgames` SET `views` = '+1' WHERE `flashgames`.`gameid` = 1;"
KazeFlame is offline   Reply With Quote
Old 10-26-2012, 02:50 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,645
Thanks: 4
Thanked 2,450 Times in 2,419 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
This is a SQL issue, not a PHP one.
You cannot increment in SQL, you must set the value to its increment. That would be a simple SET `views` = `views` + 1.
Fou-Lu is offline   Reply With Quote
Old 11-05-2012, 06:11 AM   PM User | #3
paulinetaylor85
New Coder

 
Join Date: Oct 2012
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
paulinetaylor85 is an unknown quantity at this point
You will insert a new table via using SQL code add your column follow it. I have given the example. Insert into Stu_Table values(1,'name');
paulinetaylor85 is offline   Reply With Quote
Old 11-05-2012, 04:56 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,645
Thanks: 4
Thanked 2,450 Times in 2,419 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by paulinetaylor85 View Post
You will insert a new table via using SQL code add your column follow it. I have given the example. Insert into Stu_Table values(1,'name');
Um, what? Are you referring to the use of an auto increment pk? That will have no practical purpose on this issue; the OP is incrementing a different field in the db, not the primary key (which cannot be incremented as shown in the op as that would eventually cause conflict on other pk).
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


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

Forum Jump


All times are GMT +1. The time now is 03:48 AM.


Advertisement
Log in to turn off these ads.