复选框根据数据库中的值自动检查

问题描述:

how can I auto check the checkbox based on the value from the database? I have the following code:

<input type="checkbox" name="CarModel" value="Yes"  ($row[CarModel]==Audi? 'checked' : '') >

如何根据数据库中的值自动选中复选框? 我有以下代码: p>

 &lt; input type =“checkbox”name =“CarModel”value =“Yes”($ row [CarModel] == Audi?')  ':'')&gt; 
  code>  pre> 
  div>

it should be like this

<input type="checkbox" name="CarModel" value="Yes"  <?php echo ($row['CarModel'] == 'Audi' ) ? 'checked' : NULL ; ?> >