开发者

Voting Method - Mysql

I want to use two buttons to increment two fields in a database table according to selection.

Field 1: blue
Field 2: yellow

For example:

Blue:   (3)    - Select (+1) - Button 1 (increment the #3)
Yellow: (5)    - Select (+1) - Button 2 (increment the #5)

How is this very simple code possible in php?

I already know how to make the connection.php..

what else?

Details:

say database name is voting: there are two fields, blue and yellow. People can vote for their favorite color: 开发者_开发知识库blue or yellow. Click a button or radio in order to increment them values, using a submit or autoupdate (which ever easier)


if ($_GET['input']=="blue") $Field="Field 1"; 
elseif ($_GET['input']=="yellow") $Field="Field 2";
else echo "error";

mysql_query("UPDATE table SET $Field=$Field+1 WHERE Condition");

be a little more specific please.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜