Forum Moderators: open

Message Too Old, No Replies

Simple MYSQL help

         

andrewsmd

1:23 am on Aug 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am creating a simple application for school and I need some MYSQL help because I am new at it. I have three columns in a table trogdor, sun and total. Basically if a user clicks trogdor I want to increment trogdor by one and if the user clicks sun then I want to increment sun by one. How do I update a table. Meaning when the user clicks submit I find what they checked and then either make trogdor go up by 1 or sun go up by 1. The table name is poll here is my create table syntax if you need it.CREATE TABLE poll (id int(11) NOT NULL auto_increment PRIMARY KEY, trogdor int(11), sun int(11), total decimal(11,2));

coopster

4:56 pm on Aug 30, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You will need to know the row identifier for the associated
trogdor
/
sun
columns that you want to update. Let's say it was your AUTO_INCREMENT column id of 7. Your query would then look something like this ...
// user clicked on trogdor: 
UPDATE poll SET trogdor = trogdor + 1 WHERE id = 7;
// user clicked on sun
UPDATE poll SET sun = sun + 1 WHERE id = 7;