日期:2014-05-17  浏览次数:20453 次

成绩怎么求出来? 高手进来说下思路
PHP code

<?php
    $strConn="odbc:driver={microsoft access driver (*.mdb)};dbq=".realpath("db.mdb");
    $conn = new PDO($strConn);
    if($_POST["tj"]=="交卷"){
                 //求成绩和
        
        exit();
    }
    
?>

<form action='' method="post">
<table id="t2" width="100%" border="0" align="left" cellpadding="0" cellspacing="1" bgcolor="#EFEFEF" style="text-align:left;">
<?php
    for($i=1;$i<=8;$i++){
    $y=mt_rand(1,20);
    $dsn = $conn->query('select * from st where id='.$y);
    $row = $dsn->fetch();
    $str=$row['daan'];
    $q=explode("|",$str);
        echo '<tr>';
        echo '<td height="25" colspan="2" bgcolor="#FFFFFF" style="padding-left:10px;">';
    echo   $i.'.'.$row['s_name'].'<br />';
        echo '<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">';
    echo '<tr><td><ul>';
    echo '<input type="hidden" name="act" value="'.$row['id'].'">';
        echo '<li><input type="radio" name="q'.$i.'" value="A" />'.$q[0].'</li>';
        echo '<li><input type="radio" name="q'.$i.'" value="B" />'.$q[1].'</li>';
        echo '<li><input type="radio" name="q'.$i.'" value="C" />'.$q[2].'</li>';
    echo '<li><input type="radio" name="q'.$i.'" value="D" />'.$q[3].'</li></ul></td>';
        echo '</tr>';
          echo '</table></td>';
    echo '</tr>';
    }
?>
<input type="submit" name="tj" value="交卷"/>
  </table>
    
</form>


老师要求我们写个考试系统,
  要求:
  1.随即从数据库取8条试题(不可重复)
  2.然后就是求成绩了,(这难到了我)
   
  听说PHP版有很多高手,求思路,求例子

------解决方案--------------------
把题目的id和答题者对该题的答案提交到后台,然后根据id选出正确的答案对比,记录分数求和。
------解决方案--------------------
1.过滤post过来不需要的数据
2.数组和 直接有函数

helloyou0大吃一斤...这作业有什么难度?