<?
ob_start();
include_once("conn.php");
include_once("header.php");
function format($content){
$content = str_replace("\n","<br>",str_replace(" ","$nbsp",$content));
htmlspecialchars($content);
return $content;
}
if(isset($_POST[del]))
{
$del = $_POST[del];
foreach($del as $a => $b)
{
$sql = "DELETE FROM `question` WHERE `question`.`id`=$b";
//echo $sql;
mysql_query($sql);
}
}
//print_r($del);
?>
<!--<script langage=javascript>
function checker(){
ques.deletes.value="";
if(!ques.delete.length)
{
if(ques.delete.checked)
ques.deletes.value=ques.delete.value;
}
else
{
for(i=0;i<ques.delete.length;i++)
{
if(ques.delete(i).checked)
{
ques.deletes.value = ques.delete(i).value;
for(j=i+1;j<ques.delete.length;j++)
{
if(ques.delete(j).checked)
{
ques.deletes.value +=" ";
ques.deletes.value +=ques.delete(j).value;
}
}
break;
}
}
}
return true;
}
</script> -->
<h2 align=center>欢迎来到管理页面</h2>
<br><br>
<?
$pagec=30;
if($_POST[user]!='')
{
$sql = "SELECT `password` FROM `admin` WHERE `uid` = '$_POST[user]'";
//echo $sql;
$re = mysql_query($sql,$conn);
$row = mysql_fetch_array($re);
//echo $row[password];
if($_POST[password] == $row[password])
{
setCookie('ot','login');
echo "<p align = center> 登陆成功 o(∩_∩)o ";
echo "<script language=\"javascript\">location.href='admin.php';</script>";
}
else
echo "<p align=center>用户名或密码输入错误!";
}
if($_COOKIE['ot']!='login')
{
?>
<form action = "" name = "login" method = "POST">
<table align=center>
<tr>
<td>用户名:</td><td><input type="text" name = "user"></td>
</tr>
<tr>
<td>密码:</td><td><input type="password" name = "password"></td>
</tr>
<tr><td colspan=2 align=center><input type = "submit" value=登陆></td></tr>
</table>
</form>
<?
}else{
include_once("add.php");
?>
<form name=ques id=ques action="" method=POST>
<table width=1000 align=center>
<tr bgcolor = #CFE5FF>
<th width=30>ID</th><th>单元</th><th>题目</th><th>选项内容</th><th>答案</th><th width=60>删除?</th>
</tr>
<?
$page = 1;
$maxpage;
$url = $_SERVER["REQUEST_URI"];
$url = parse_url($url);
$url = $url[path];
if($_GET[page]){
$page=$_GET[page];
if($_GET[page]=0)
{
$page=1;
}
}
$numq = mysql_query("SELECT * FROM `question`");
$num = mysql_num_rows($numq);
$maxpage=ceil($num/$pagec)+1;
//echo $maxpage;
$sql = "SELECT * FROM `question` limit ".($page-1)*$pagec.",$pagec";
//echo $sql;
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
?>
<tr bgcolor = #EFEFEF>
<td><?=$row[id]?></td><td><?=$row[unit]?></td><td><?=format($row[title])?></td><td><?=$row[collect]?></td><td><? if ($row[ca] == -1) echo 此为简答题;else echo $row[ca];?></td><td><input type=checkbox name = "del[]" value=<?=$row[id]?>></td>
</tr>
<?}?>
<tr><td align=center colspan=6><input type=submit value=保存更改></td></tr>
</table>
</form>
<p align=right>
<?
$turn = "共有 $maxpage 页 , 当前第 $page 页.";
if($page == 1)
$turn=$turn."<a href=$url?page=".($page+1).">下一页</a>";
else if($page >= $maxpage)
$turn=$turn."<a href=$url?page=".($page-1).">上一页</a>";
else $turn=$turn."<a href=$url?page=".($page-1).">上一页</a><a href=$url?page=".($page+1).">下一页</a>";
echo $turn;
?>           </p>
<h2 align=center> 发布考试 </h2>
<form action="" method=POST><p align=center >请输入考试ID : <input name=testid><input type=submit value=生成></p></form>
<? if(isset($_POST[testid]))
{
$testid=$_POST[testid];
echo "<p align=center><a href='./test.php?unit=$testid'>第 $testid 单元考试</a></p>";
}
?>
<?
}
include_once("footer.php");
?>
评论3
最新资源