 |
|
ช่วนหน่อยเนอะค่ะ แก้นานแร้ว ไม่รุจาเขียนยังงั้น ตอนนี้เก็บคะแนนการทำแบบทดสอบได้แร้วค่ะ แต่มันไม่เช็คว่าใครเปงคนทำแบบทดสอบ คือมันเก็บแค่คะแนนได้อ่ะค่ะ
ส่วนฐานข้อมูลที่เก็บคะแนนค่ะ

ส่วนโค้ดค่ะ
<style type="text/css">
<!--
body {
background-color: #FF9900;
}
-->
</style><?
$correct=0;
$total=count($total_question);
include "connect.php";
$sql="select id,answer from tb_test order by id";
$result=mysql_db_query("$dbname",$sql);
while ($r=mysql_fetch_array($result)) {
$id=$r[id];
$answer=$r[answer];
if (in_array($id, $total_question)) {
$select="select_".$id;
if (${$select}==$answer) {
$correct++;
}
}
}
$link=mysql_connect("localhost","root","root");
if (!$link)
{
print("ERROR");
}
else
{
mysql_select_db("db_test",$link);
$sql="insert into tb_member (id,username,score_mid)
values ('$id,$username,$correct')";
$res = mysql_query( $sql , $link );
if ($res==1)
print("Adding to table OK.");
else
print("Error Adding to table. ");
}
echo "<h2 align='center'>ถูกต้องทั้งหมด $correct ข้อ<BR>แบบทดสอบทั้งหมด $total ข้อ</h2>";
echo "<meta http-equiv=refresh content=3;URL=../flash/fhome.php>";
?>
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
2010-03-15 16:23:53 |
By :
aa |
View :
1020 |
Reply :
0 |
|
 |
 |
 |
 |
|
|
|
 |