PHP:从数据库检索时,防止在复选框旁边显示值
我正在将复选框值存储到数据库(1s和0s)并从中检索。它工作正常,但是在检索值时如何防止值显示在复选框旁边?谢谢 我使用如下代码从数据库中检索值:PHP:从数据库检索时,防止在复选框旁边显示值,php,Php,我正在将复选框值存储到数据库(1s和0s)并从中检索。它工作正常,但是在检索值时如何防止值显示在复选框旁边?谢谢 我使用如下代码从数据库中检索值: if($firstVal != 0){ $output .= ' <td style="text-align:center;"><input type="checkbox" data-id1="'.$row["checkid"].'" name="chk1" id="chk1" value="1" checked=
if($firstVal != 0){
$output .= '
<td style="text-align:center;"><input type="checkbox" data-id1="'.$row["checkid"].'" name="chk1" id="chk1" value="1" checked="checked">'.$row["firstrating"].'</td>
';
} else {
$output .= '
<td style="text-align:center;"><input type="checkbox" data-id1="'.$row["checkid"].'" name="chk1" id="chk1" value="1">'.$row["firstrating"].'</td>
';
}
if($firstVal!=0){
$output.='
“.$row[“firstrating”]”
';
}否则{
$output.='
“.$row[“firstrating”]”
';
}
我认为您必须删除:
输入后的“.$row[“firstrating”]”使用
if-else
简写如下
$output .= '<td style="text-align:center;"><input type="checkbox" data-id1="'.$row["checkid"].'"name="chk1" id="chk1" value="1" <?= ($firstVal != 0) ? "checked" : "";?>>'.$row["firstrating"].'</td>';
$output.='Remove'.$row[“firstrating”]。
,我假设这是一个值?只需删除$row[“firstrating”]这个变量即可。这就是汉克斯!删除$row[“firstrating”]后,它现在工作正常。谢谢!删除$row[“firstrating”]后,它现在工作正常。