Php 如何在多个选定的学生id中进行计数

Php 如何在多个选定的学生id中进行计数,php,Php,我有两张桌子,第一张和第二张。在初始投票表上,它由userid和choices1-4(studid)组成,我在这里存储所选学生id尚未统计的信息。在studinfo表中,这是我想要计算numvote列的地方 初始投票表 userid choice1 choice2 choice3 choice4 12345 c-1234 c-1134 c-1222 c-1345 23456 c-1674

我有两张桌子,第一张和第二张。在初始投票表上,它由userid和choices1-4(studid)组成,我在这里存储所选学生id尚未统计的信息。在studinfo表中,这是我想要计算numvote列的地方

初始投票表

     userid     choice1    choice2     choice3     choice4
     12345      c-1234     c-1134      c-1222      c-1345 
     23456      c-1674     c-1534      c-1342      c-1444
studinfo表

     studid     fname    lname     mname     numvote
     c-1234     maria    cruz      santos       
     c-1134     juan     santos    cris
     c-1222     borg     sample    bern
     c-1345     joy      girl      cute
我设法从如下所示的初始投票中获得用户选择1-4的studid

      $vote$_SESSION['userid'];
     function getinfo2($info2){
    global $voter; //lets say the userid here is 12345
    $info_select = "SELECT `$info2` FROM `initial_vote` WHERE `voter_studid`='".mysql_real_escape_string($voter)."'";
            if ($query_get = mysql_query($info_select)) { 
            if ($result = mysql_result($query_get, 0, $info2)) {
            return $result;
            }
            }
            }
     $c1 = getinfo2('choice1'); $c2 = getinfo2('choice2'); 
     $c3 = getinfo2('choice3'); $c4 = getinfo2('choice4');
但我现在的问题是,当我单击提交按钮时,如何添加或制作一个函数来计算最终投票表(NumNote列)中选定的studid。我尽了最大努力,但没有成功

 if($_POST['submit']{
    // ????
 }else { echo "Not added"; }

. 它们不再得到维护。看到了吗?相反,学习,并使用or-将帮助您决定哪一个。如果您选择PDO,。您需要规范化您的
初始投票
table@njk&thaJeztah。。。。thnks用于响应