如果复选框中的值与数据库中的值相同,我尝试在我的复选框中添加选中:
My database :
Column = skin_type
Value = Normal, Dry, Oily
My Default html checkbox :
<input type="checkbox" name="skin_type[]" value="Normal">Normal
<input type="checkbox" name="skin_type[]" value="Dry">Dry
<input type="checkbox" name="skin_type[]" value="Oily">Oily
<input type="checkbox" name="skin_type[]" value="Combination">Combination
<input type="checkbox" name="skin_type[]" value="Sensitive">Sensitive
所以如果值是Normal, Dry, Oily
复选框,这个值将被选中,如下所示
下面是我当前的 php 脚本(我尝试先分解数据,但不确定如何添加检查值是否与数据库中的值相等):
<?php
$query_skin_type = mysql_query("SELECT skin_type FROM `customers` WHERE customers_id='".$_GET['cID']."'");
while($info = mysql_fetch_array($query_skin_type)) {
$skin_type = explode(", ", $info['skin_type']);
foreach ($skin_type as $value) {
$value.'<br>';
}
}
?>