我正在显示一个问题及其选项。我想使用限制查询。
但我收到了错误。如果我在$query
字符串中使用任何其他查询,我没有收到任何错误。
<?php
$dbc = mysqli_connect('localhost','root','1234','myown')
or die('unable to connect');
// $query = "Select * from question";
// $result = mysqli_query($dbc,$query);
// $num_rows = mysqli_num_rows($result);
$range = rand(0,6);
echo $range;
$query = "select * from question where limit 1,1";
$result = mysqli_query($dbc,$query)
or die("Error.\n");
$row = mysqli_fetch_array($result);
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h3> <?php echo $row['sawal']; ?></h3>
<form method = "POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="radio" name=" answer" value="A" ><?php echo $row['A']; ?><br>
<input type="radio" name=" answer" value="B" ><?php echo $row['B']; ?><br>
<input type="radio" name=" answer" value="C" ><?php echo $row['C']; ?><br>
<input type="radio" name=" answer" value="D" ><?php echo $row['D']; ?><br>
<input type="submit" name="submit" value="ANSWER"/>
</form>
</body>
</html>
<?php
mysqli_close($dbc);
?>
我怎样才能克服它?
答案 0 :(得分:3)
$query = "select * from question limit 1,1";
答案 1 :(得分:0)
你从1开始你的LIMIT并结束到1 ..因为你得到错误.. 试试这个
“你的查询”(不要在这里使用where语句)LIMIT 0,1;