2套单选按钮php我的sql

时间:2017-02-06 06:57:03

标签: php jquery mysql

我正在为我的大学项目制作一个调查系统。但是我很难用单选按钮。我成功地制作了一组单选按钮,它的值被发送到我的数据库。但是当我制作两组单选按钮时,只有第一组单选按钮被发送到我的数据库。有人能帮助我吗?

if (isset($_GET['Submit1']) && isset($_GET['q']) && isset($_GET['q1'])) {

    $selected_radio = $_GET['q'];
    $selected_radio2 = $_GET['q1'];



    $idNumber = $_GET['h1'];



$user_name = "root";
$password = "";
$database = "survey";
$server = "127.0.0.1";

$db_found = new mysqli($server,$user_name, $password, $database );

    if ($db_found) {

        if($selected_radio == "A") {
            $votedSQL = "UPDATE tblsurvey SET VotedA = VotedA + 1 WHERE ID = ?";
            $voteMessage = insert_vote($db_found, $votedSQL, $idNumber);
        }
        else if($selected_radio == "B"){
            $votedSQL = "UPDATE tblsurvey SET VotedB = VotedB + 1 WHERE ID = ?";
            $voteMessage = insert_vote($db_found, $votedSQL, $idNumber);
        }
        else if($selected_radio == "C"){
            $votedSQL = "UPDATE tblsurvey SET VotedC = VotedC + 1 WHERE ID = ?";
            $voteMessage = insert_vote($db_found, $votedSQL, $idNumber);
        }
        else if($selected_radio2 == "D") {
            $votedSQL = "UPDATE tblsurvey SET VotedD = VotedD + 1 WHERE ID = ?";
            $voteMessage = insert_vote($db_found, $votedSQL, $idNumber);
        }
        else if($selected_radio2 == "E"){
            $votedSQL = "UPDATE tblsurvey SET VotedE = VotedE + 1 WHERE ID = ?";
            $voteMessage = insert_vote($db_found, $votedSQL, $idNumber);
        }
        else if($selected_radio2 == "F"){
            $votedSQL = "UPDATE tblsurvey SET VotedF = VotedF + 1 WHERE ID = ?";
            $voteMessage = insert_vote($db_found, $votedSQL, $idNumber);
        }
        else {
            print "Error - could not record vote";
        }   
    }
}

else {
    print "You didn't select a voting option!";

1 个答案:

答案 0 :(得分:0)

尝试差异组的差异名称

<input type="radio" name="group1" value="group12"> group12<br>
<input type="radio" name="group1" value="group123"> group123<br>

<input type="radio" name="group2" value="group2"> group2<br>
<input type="radio" name="group2" value="group23"> group23