tt
This commit is contained in:
32
test.php
32
test.php
@@ -7,17 +7,17 @@
|
|||||||
$m = floor($sec/60);
|
$m = floor($sec/60);
|
||||||
$s = floor($sec%60);
|
$s = floor($sec%60);
|
||||||
//link to mysql
|
//link to mysql
|
||||||
$con=mysqli_connect("localhost","buptStudent","buptStudentlx","buptStudentdb");
|
$con=mysql_connect("localhost","buptStudent","buptStudentlx","buptStudentdb");
|
||||||
if (!$con){die('Could not connect: '.mysql_error());}
|
if (!$con){die('Could not connect: '.mysql_error());}
|
||||||
//mysql_select_db("my_db_test", $con);
|
//mysql_select_db("my_db_test", $con);
|
||||||
//name & student_id
|
//name & student_id
|
||||||
$chongfu="SELECT Student_ID FROM UserAnswer WHERE Student_ID=$_POST[student_id]";
|
$chongfu="SELECT Student_ID FROM UserAnswer WHERE Student_ID=$_POST[student_id]";
|
||||||
if(mysqli_fetch_array(mysqli_query($chongfu,$con))[0]==$_POST[student_id])
|
if(mysql_fetch_array(mysql_query($chongfu,$con))[0]==$_POST[student_id])
|
||||||
{
|
{
|
||||||
die('对不起,您已参与过本活动。');
|
die('对不起,您已参与过本活动。');
|
||||||
}
|
}
|
||||||
$sql="INSERT INTO UserAnswer (user_name, Student_ID, school, userclass, phone, ip, timeend ,timestart, thetime) VALUES ('$_POST[user_name]','$_POST[student_id]','$_POST[school]','$_POST[userclass]','$_POST[telephone]','$userIp','$timeend','$_POST[timestart]','$sec')";
|
$sql="INSERT INTO UserAnswer (user_name, Student_ID, school, userclass, phone, ip, timeend ,timestart, thetime) VALUES ('$_POST[user_name]','$_POST[student_id]','$_POST[school]','$_POST[userclass]','$_POST[telephone]','$userIp','$timeend','$_POST[timestart]','$sec')";
|
||||||
if (!mysqli_query($sql,$con))
|
if (!mysql_query($sql,$con))
|
||||||
{
|
{
|
||||||
die("提交失败,请稍后重试。");
|
die("提交失败,请稍后重试。");
|
||||||
}
|
}
|
||||||
@@ -27,39 +27,39 @@
|
|||||||
for($i=1;$i<=$qn;$i++){
|
for($i=1;$i<=$qn;$i++){
|
||||||
$a = "answer_".$i;
|
$a = "answer_".$i;
|
||||||
//$sql = "UPDATE UserAnswer SET $a=$_POST[$a] WHERE Student_ID=$_POST[student_id]";
|
//$sql = "UPDATE UserAnswer SET $a=$_POST[$a] WHERE Student_ID=$_POST[student_id]";
|
||||||
//if (!mysqli_query($sql,$con))
|
//if (!mysql_query($sql,$con))
|
||||||
// {
|
// {
|
||||||
// $sql2="ALTER TABLE UserAnswer ADD $a INT(11) NOT NULL";
|
// $sql2="ALTER TABLE UserAnswer ADD $a INT(11) NOT NULL";
|
||||||
// mysqli_query($sql2,$con);
|
// mysql_query($sql2,$con);
|
||||||
// mysqli_query($sql,$con);
|
// mysql_query($sql,$con);
|
||||||
// }
|
// }
|
||||||
$b= "question_".$i;
|
$b= "question_".$i;
|
||||||
//$sql3 = "UPDATE UserAnswer SET $b=$_POST[$b] WHERE Student_ID=$_POST[student_id]";
|
//$sql3 = "UPDATE UserAnswer SET $b=$_POST[$b] WHERE Student_ID=$_POST[student_id]";
|
||||||
//if (!mysqli_query($sql3,$con))
|
//if (!mysql_query($sql3,$con))
|
||||||
// {
|
// {
|
||||||
// $sql4="ALTER TABLE UserAnswer ADD $b INT(11) NOT NULL";
|
// $sql4="ALTER TABLE UserAnswer ADD $b INT(11) NOT NULL";
|
||||||
// mysqli_query($sql4,$con);
|
// mysql_query($sql4,$con);
|
||||||
// mysqli_query($sql3,$con);
|
// mysql_query($sql3,$con);
|
||||||
// }
|
// }
|
||||||
$c= "aq_".$i;
|
$c= "aq_".$i;
|
||||||
$d=$_POST[$a]+$_POST[$b]*10;
|
$d=$_POST[$a]+$_POST[$b]*10;
|
||||||
$sql5 = "UPDATE UserAnswer SET $c=$d WHERE Student_ID=$_POST[student_id]";
|
$sql5 = "UPDATE UserAnswer SET $c=$d WHERE Student_ID=$_POST[student_id]";
|
||||||
if (!mysqli_query($sql5,$con))
|
if (!mysql_query($sql5,$con))
|
||||||
{
|
{
|
||||||
$sql6="ALTER TABLE UserAnswer ADD $c INT(11) NOT NULL";
|
$sql6="ALTER TABLE UserAnswer ADD $c INT(11) NOT NULL";
|
||||||
mysqli_query($sql6,$con);
|
mysql_query($sql6,$con);
|
||||||
mysqli_query($sql5,$con);
|
mysql_query($sql5,$con);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//match & score
|
//match & score
|
||||||
//$result = mysqli_query("SELECT * FROM UserAnswer WHERE Student_ID=$_POST[student_id]");
|
//$result = mysql_query("SELECT * FROM UserAnswer WHERE Student_ID=$_POST[student_id]");
|
||||||
//$row = mysqli_fetch_array($result);
|
//$row = mysql_fetch_array($result);
|
||||||
//$g=0;
|
//$g=0;
|
||||||
//for($i=1;$i<=$qn;$i++){
|
//for($i=1;$i<=$qn;$i++){
|
||||||
// $b="answer_".$i;
|
// $b="answer_".$i;
|
||||||
// $c=$row[$b];
|
// $c=$row[$b];
|
||||||
// $d=mysqli_query("SELECT answer FROM Persons WHERE num=$i");
|
// $d=mysql_query("SELECT answer FROM Persons WHERE num=$i");
|
||||||
// $e=mysqli_fetch_array($d)['answer'];
|
// $e=mysql_fetch_array($d)['answer'];
|
||||||
//$d=$answer_row[$b];
|
//$d=$answer_row[$b];
|
||||||
// if($c==$e) $g++;
|
// if($c==$e) $g++;
|
||||||
//echo "No.".$i." your choice is ".$c." answer is ".$e."<br />";
|
//echo "No.".$i." your choice is ".$c." answer is ".$e."<br />";
|
||||||
|
|||||||
Reference in New Issue
Block a user