刷题网页--前端答题
showshiti.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
</style>
<title>全部信息</title>
</head>
<body>
<title>全部信息</title>
</head>
<body>
<?php
$page =isset($_GET['page'])?$_GET['page']:1;
$db=new mysqli("localhost","root","123456","shuati");
if ($db->connect_error)
{
die($db->connect_error);
}
$page =isset($_GET['page'])?$_GET['page']:1;
$db=new mysqli("localhost","root","123456","shuati");
if ($db->connect_error)
{
die($db->connect_error);
}
$sqlall = "select * from shiti";
$resultall = $db-> query($sqlall);
$total_page=$resultall->num_rows;
$resultall = $db-> query($sqlall);
$total_page=$resultall->num_rows;
$sql = "select * from shiti where Id=$page";
$result = $db-> query($sql);
while($attr=$result->fetch_row())
{
echo
"
第{$attr[0]}题<br />
{$attr[1]}
答案:{$attr[2]}<br />
提示:{$attr[3]}<br />";
$xxxx=$attr[2];
$tishi=$attr[3];
}
"
第{$attr[0]}题<br />
{$attr[1]}
答案:{$attr[2]}<br />
提示:{$attr[3]}<br />";
$xxxx=$attr[2];
$tishi=$attr[3];
}
echo "<script>var jsanswer=\"$xxxx\";var tishi=\"$tishi\";</script>";
echo '<a href="showshiti.php">首题</a>';
if($page > 1){
echo '<a href="showshiti.php?page='.($page-1).'">上一题</a>';
echo ' ';
}
if($page < $total_page){
echo '<a href="showshiti.php?page='.($page+1).'">下一题</a>';
echo ' ';
}
echo '<a href="showshiti.php?page='.$total_page.'">尾题</a>';
?>
<hr />
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
答案是:<input type="text " id="youranswer" /><br />
<input type="button" value="提交答案" onClick="huode()"/>
</form>
<script>
function huode(){
var vDiv1 = document.getElementById("youranswer").value;
if(vDiv1==jsanswer)
{alert("答案正确");}
else
{alert("答案错误");}
}
function huode(){
var vDiv1 = document.getElementById("youranswer").value;
if(vDiv1==jsanswer)
{alert("答案正确");}
else
{alert("答案错误");}
}
function showanswer(){
document.getElementById('div1').innerHTML=tishi;
document.getElementById('div1').innerHTML=tishi;
}
</script>
<br />
<input type="button" onclick="showanswer()" value="花10个金币看提示">
<br />
<div id="div1"></div>
</script>
<br />
<input type="button" onclick="showanswer()" value="花10个金币看提示">
<br />
<div id="div1"></div>
</body>
</html>

浙公网安备 33010602011771号