php+mysql 개발 의 가장 간단 한 온라인 문제 라 이브 러 리(온라인 문제 풀이 시스템)전체 사례
문제 고 는 교육 기구,학교,온라인 교육 에 있어 필요 하 다.인터넷 에 도 제3자 온라인 문제 창고 시스템 이 적지 않다.그러나 이번 사례 는 필요 한 사람 에 게 문제 창고 의 개발 방향 을 이해 하 게 할 것 이다.사실은 매우 간단 하 다.단지 하나의 폼 검증,데이터 창고 검증 일 뿐이다.
1.폼 데이터 구축
2.폼 데 이 터 를 get 또는 post 방식 으로 폼 인증 페이지 에 제출 하여 데이터베이스 와 일치 시 킵 니 다.
3.결 과 를 되 돌려 주 고 정 답 또는 오류
빌 드 폼:
index.php
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<title> </title>
<style type="text/css">
*{list-style: none;margin:0px;padding: 0px;}
#tiku{
width: 300px;
margin:10px auto;
}
#tiku ul li{
float: left;
}
</style>
</head>
<body>
<?php
//
require_once("config.php");
//
$con = mysql_connect($host,$username,$password);
//
mysql_query("SET NAMES UTF8");
//
mysql_select_db($db, $con);
//
// 1
$all = mysql_num_rows(mysql_query("select * from $tb"));
//
$lenght=1; //
@$page=$_GET['page']?$_GET['page']:1; //
$offset=($page-1)*$lenght; //
$allpage=ceil($all/$lenght); // -
$prepage=$page-1; //
if($page==1){
$prepage=1; // 1 1
}
$nextpage=$page+1;
if($page==$allpage){
$nextpage=$allpage; //
}
$sql="select * from $tb order by id ASC limit {$offset},{$lenght}";
$rest=mysql_query($sql);
while($row = mysql_fetch_assoc($rest))
{
$id = $row["id"];
$title = $row["title"];
$A = $row["answer_A"];
$B = $row["answer_B"];
$C = $row["answer_C"];
$D = $row["answer_D"];
$true = $row["true"];
$score = $row["score"];
}
?>
<div id="tiku">
<form action="check.php" method="get">
<p><?php echo $title;?></p>
<input type="radio" name="xuanxiang" value="<?php echo $A;?>">A:<?php echo $A;?><br>
<input type="radio" name="xuanxiang" value="<?php echo $B;?>">B:<?php echo $B;?><br>
<input type="radio" name="xuanxiang" value="<?php echo $C;?>">C:<?php echo $C;?><br>
<input type="radio" name="xuanxiang" value="<?php echo $D;?>">D:<?php echo $D;?><br><br>
<input type="hidden" name="id" value="<?php echo $id;?>">
<button> </button>
</form>
</div>
<br/>
<?php
echo "<div id='tiku'>";
echo "<ul>";
echo "<li><a href='next.php?page=$prepage'> </a></li>";
echo "<li><a href='next.php?page=$nextpage'> </a></li>";
echo "</ul>";
echo "<div>";
echo "<br/>";
echo "<p class='fenye_tips'> ".$allpage." , ".$page." </p>";
echo "<br/><br/>";
echo "</div>";
?>
</body>
</html>
양식 접수check.php
<?php
header("Content-type:text/html;charset=utf-8");
//
require_once("config.php");
//
$con = mysql_connect($host,$username,$password);
//
mysql_query("SET NAMES UTF8");
//
mysql_select_db($db, $con);
//
$xuanxiang = $_GET["xuanxiang"];
$id = $_GET["id"];
if (empty($xuanxiang)) {
echo "<script>alert(' !');history.go(-1);</script>";
}else{
//
$result = mysql_query("SELECT * FROM $tb WHERE id =".$id);
while($row = mysql_fetch_array($result))
{
$true = $row["true"];
$next_id = $id+1;
if($xuanxiang == $true){
echo "<script>alert(' ! 5 !');location.href='next.php?page=$next_id';</script>";
}else{
echo "<script>alert(' ! 5 !');history.go(-1);</script>";
}
}
}
?>
데이터베이스 설정config.php
<?php
// - BY TANKING
$host=" ";
$username=" ";
$password=" ";
$db=" ";
$tb = " ";
?>
next.php다음 문제
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<title> </title>
<style type="text/css">
*{list-style: none;margin:0px;padding: 0px;}
#tiku{
width: 300px;
margin:10px auto;
}
#tiku ul li{
float: left;
}
</style>
</head>
<body>
<?php
//
require_once("config.php");
//
$con = mysql_connect($host,$username,$password);
//
mysql_query("SET NAMES UTF8");
//
mysql_select_db($db, $con);
//
// 1
$all = mysql_num_rows(mysql_query("select * from $tb"));
//
$lenght=1; //
@$page=$_GET['page']?$_GET['page']:1; //
$offset=($page-1)*$lenght; //
$allpage=ceil($all/$lenght); // -
$prepage=$page-1; //
if($page==1){
$prepage=1; // 1 1
}
$nextpage=$page+1;
if($page==$allpage){
$nextpage=$allpage; //
}
$sql="select * from $tb order by id ASC limit {$offset},{$lenght}";
$rest=mysql_query($sql);
while($row = mysql_fetch_assoc($rest))
{
$id = $row["id"];
$title = $row["title"];
$A = $row["answer_A"];
$B = $row["answer_B"];
$C = $row["answer_C"];
$D = $row["answer_D"];
$true = $row["true"];
$score = $row["score"];
}
?>
<div id="tiku">
<form action="check.php" method="get">
<p><?php echo $title;?></p>
<input type="radio" name="xuanxiang" value="<?php echo $A;?>">A:<?php echo $A;?><br>
<input type="radio" name="xuanxiang" value="<?php echo $B;?>">B:<?php echo $B;?><br>
<input type="radio" name="xuanxiang" value="<?php echo $C;?>">C:<?php echo $C;?><br>
<input type="radio" name="xuanxiang" value="<?php echo $D;?>">D:<?php echo $D;?><br><br>
<input type="hidden" name="id" value="<?php echo $id;?>">
<button> </button>
</form>
</div>
<br/>
<?php
echo "<div id='tiku'>";
echo "<ul>";
echo "<li><a href='next.php?page=$prepage'> </a></li>";
echo "<li><a href='next.php?page=$nextpage'> </a></li>";
echo "</ul>";
echo "<div>";
echo "<br/>";
echo "<p class='fenye_tips'> ".$allpage." , ".$page." </p>";
echo "<br/><br/>";
echo "</div>";
?>
</body>
</html>
데이터베이스 구조제목
answer_A---정 답 A
answer_B---정 답 B
answer_C---정 답 C
answer_D---정 답 D
정 답
득점
더 많은 PHP 관련 내용 에 관심 이 있 는 독자 들 은 본 사이트 의 주 제 를 볼 수 있다.
본 논문 에서 말 한 것 이 여러분 의 PHP 프로 그래 밍 에 도움 이 되 기 를 바 랍 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Laravel - 변환된 유효성 검사 규칙으로 API 요청 제공동적 콘텐츠를 위해 API를 통해 Laravel CMS에 연결하는 모바일 앱(또는 웹사이트) 구축을 고려하십시오. 이제 앱은 CMS에서 번역된 콘텐츠를 받을 것으로 예상되는 다국어 앱이 될 수 있습니다. 일반적으로 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.