HTML中的CHECKBOX PHP [关闭]

我想制作此代码,以便在选中该复选框以从sql提取数据并打印它们时显示,但在我尝试时会显示> Notice:Undefined index:test on C:\ xampp \ htdocs \ HTML PROJECT \ index.php 46行

<html>
<body> 
<input name="test" value="true" type="checkbox"/>
<?php
$db = mysqli_connect('localhost', 'root', '', 'restorant');
$checkbox1 = $_POST['test'];
if($checkbox1 == 'true'){
   $sql = "SELECT * FROM images WHERE pnumber ='1'";
   $result = mysqli_query($db, $sql);
while ($row = mysqli_fetch_array($result)){
    echo "<p>Name: ".$row['text']."</p>";
    echo "<p>Price: $".$row['price']."</p>";
    echo "</div>";
}
}
?>
</body>
评论