Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP:从数据库检索时,防止在复选框旁边显示值_Php - Fatal编程技术网

PHP:从数据库检索时,防止在复选框旁边显示值

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=

我正在将复选框值存储到数据库(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="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”]后,它现在工作正常。