Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Sep 2012
    Location
    Philippines
    Posts
    11
    Thanks
    9
    Thanked 0 Times in 0 Posts

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

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.

  • #3
    New Coder
    Join Date
    Oct 2012
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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');

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •