CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   How to add integer to a column? (http://www.codingforums.com/showthread.php?t=279510)

KazeFlame 10-26-2012 02:47 PM

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;"


Fou-Lu 10-26-2012 02:50 PM

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.

paulinetaylor85 11-05-2012 06:11 AM

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');

Fou-Lu 11-05-2012 04:56 PM

Quote:

Originally Posted by paulinetaylor85 (Post 1288632)
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).


All times are GMT +1. The time now is 07:17 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.