doujianchao7446 2015-04-04 17:21
浏览 52
已采纳

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

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' : '') >
  • 写回答

1条回答 默认 最新

  • douliang9057 2015-04-04 17:28
    关注

    it should be like this

    <input type="checkbox" name="CarModel" value="Yes"  <?php echo ($row['CarModel'] == 'Audi' ) ? 'checked' : NULL ; ?> >
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?