当我的复选框被选中时,我想这样做,我的数据库中的某些值(数据)将显示在我的网页上,但当我执行我的代码时,我的网页上会出现两条消息"警告: mysql_query()期望参数1为字符串,资源在第5行的C:\ xampp \ htdocs \ php \ checkboxes.php中给出 "和"警告:mysql_fetch_array()期望参数1是资源,在第10行"的C:\ xampp \ htdocs \ php \ checkboxes.php中给出null。我几乎尝试了一切来解决这个问题,但我做不到,所以我来这里请你帮忙。
有我的代码:
test.php:
<form action="checkboxes.php" method="post">
<input type="checkbox" name="checkbox1" value="Yes" />
<input type="submit" name="formSubmit" value="Submit" />
</form>
&#13;
config.php:
<?php
/* Database connection */
$sDbHost = 'localhost';
$sDbName = 'testowanie';
$sDbUser = 'root';
$sDbPwd = '';
$dbcon = mysql_connect ($sDbHost, $sDbUser, $sDbPwd, $sDbName);
?>
&#13;
checkboxes.php:
<?php
include('config.php');
$sqlget = "SELECT * FROM monitory";
$sqldata = mysql_query($dbcon, $sqlget);
if(isset($_POST['checkbox1']) &&
$_POST['checkbox1'] == 'Yes')
{
while($row = mysql_fetch_array($sqldata, MYSQL_ASSOC)) {
echo $row['cena'];
}
}
?>
&#13;