我正在开发一个应用程序,它有一个问题库,通过它我想随机生成问题论文。我正在使用PHP和HTML。我使用html作为我的前端和后端PHP。我已开发的代码,但是有一个问题,它,它产生4 textarea的2个问题,我无法调试它使用PHP生成随机数据
<?php
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "rgpv";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT ques FROM bank WHERE sub='$_POST[sub]' ORDER BY RAND() LIMIT 2";
$result = $conn->query($sql);
$result = $conn->query($sql);
// output data of each row
while($row = $result->fetch_assoc()) {
?>
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Login Form</title>
<!-- Calling CSS -->
<link rel="stylesheet" href="css/reset.css">
<link rel='stylesheet prefetch' href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900|RobotoDraft:400,100,300,500,700,900'>
<!--File for fonts-->
<link rel='stylesheet prefetch' href='css/bootstrap.css'>
<link rel='stylesheet prefetch' href='css/font-awesome.min.css'>
<link rel="stylesheet" href="css/style.css">
</head> <!-- end Head -->
<body background="images/journal.jpg">
<!-- Mixins-->
<!-- Form Title-->
<div class="pen-title">
<h1>University Institute of Technology- RGPV</h1><h2>Random Question Paper Generator Portal</h2>
</div>
<fieldset class="form-group">
<label for="exampleTextarea">Question 1</label>
<textarea class="form-control txt" id="name" rows="3" value="" disabled><?php echo $row["ques"]; ?></textarea>
</fieldset>
<fieldset class="form-group">
<label for="exampleTextarea">Question 2</label>
<textarea class="form-control txt" id="name" rows="3" value="" disabled><?php echo $row["ques"]; ?></textarea>
</fieldset>
</body>
</html>
<?php
}
?>
你可以从mysql中随机获取数据。如果你想随机使用PHP,那么试试rand函数。 –
您想让我们为您写信还是猜测? –
呃..Buddy你想要一些像现成的面包,为你的早餐? –