0
存在我尽量选择基于价值复选框使用破灭已经插入数据库中获取如此插入与分离数据库的价值,但当我拿出与选定的价值形式,它会选择什么chechbox检查是否值在数据库
//getting from DB
$moteur=$row['moteur'];
$moteur= explode(",",$moteur);
try to select
<th> <input type="checkbox" name="moteur[]" value="Vidange"
<?php
$count=count($moteur);
for($i=0;$i<$count;$i++)
echo ($moteur[$i]=='Vidange' ? 'checked' : 'disabled'); ?> >
</th>
<th> <input type="checkbox" name="moteur[]" value="nv"
<?php
for($i=0;$i<$count;$i++)
echo ($moteur[$i]=='nv' ? 'checked' : 'disabled'); ?> >
</th>
<th> <input type="checkbox" name="moteur[]" value="remplace"
<?php
for($i=0;$i<$count;$i++)
echo ($moteur[$i]=='remplace' ? 'checked' : 'disabled'); ?> >
</th>
<th> <input type="checkbox" name="moteur[]" value="nettoye"
<?php
for($i=0;$i<$count;$i++)
echo ($moteur[$i]=='nettoye' ? 'checked' : 'disabled'); ?> >
</th>
<th> <input type="checkbox" name="moteur[]" value="effectue"
<?php
for($i=0;$i<$count;$i++)
echo ($moteur[$i]=='effectue' ? 'checked' : 'disabled'); ?> > </th>
<th> <input type="checkbox" name="moteur[]" value="controle"
<?php
for($i=0;$i<$count;$i++)
echo ($moteur[$i]=='controle' ? 'checked' : 'disabled'); ?> >
</th>
你能喜欢,清理代码,以便它是更具可读性? –
尝试var_dump($ moteur);并根据 –
$ moteur包含的内容检查您获得的数据类型是否正确。你想在$ moteur的基础上制作复选框。 –