单击按钮时,我尝试从mysql随机获取数据,这是我的代码。
<?php
$con=mysqli_connect("localhost","root","","school");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT description From task ORDER BY RAND() LIMIT 2");
echo "<p><strong>Question:</strong></p>";
while($row = mysqli_fetch_array($result))
{
echo "<p>". $row['description'] ."</p>";
}
mysqli_close($con);
?>
<input type="button" value="Get Assignment" onclick="myfunc()">
</body>
</html>
我希望在我单击“获取分配”按钮时输出,它将显示随机问题,直到我将显示空框。
四季花海