2
我試圖檢查數組中的任何值是否與數據庫的結果相匹配,如果是,那麼我想回顯一個選中的複選框和一個填充文本輸入。檢查每個數組的值是否與數據庫的結果相匹配
這是我到目前爲止。
$faucets_checked = unserialize($rotator_websites);
$check_these = array();
for ($x = 0; $x <= (intval(count($faucets_checked))-1); $x++){
$faucet_website_checked = explode("=",$faucets_checked[$x]);
$check_these[] = $faucet_website_checked[0] . "=";
$ref_these[] = $faucet_website_checked[1];
}
//SELECTED SOME DATA FROM DATABASE
while($stmt->fetch()){
$count = 0;
while($count <= (intval(count($check_these))-1)){
$check_this = $check_these[$count];
if($check_this == $faucet_website){
$checked = "checked";
$ref_filled = "value='".$ref_these[$count]."'";
echo "<input type='checkbox' name='check[]' value='".$faucet_id."' ".$checked." /><input type='text' name='text".$faucet_id."' ".$ref_filled." />";
}else{
$checked = "";
$ref_filled = "";
echo "<input type='checkbox' name='check[]' value='".$faucet_id."' ".$checked." /><input type='text' name='text".$faucet_id."' ".$ref_filled." />";
}
$checked = "";
$ref_filled = "";
$count++;
}
}
我覺得這不會返回它應該是一個檢查框和輸入文本字段也返回另一個是不檢查,不填充。
WOW!我甚至不知道這存在。謝謝 – Dylan12
不客氣:) – skank