如果有值,检查无线电输入

时间:2011-08-09 16:51:27

标签: php mysql phpmyadmin

如果$row['featured']; = 1,如果$row['featured']; = 0未显示为已选中,我需要将广播显示为已检查

这是代码

    <?php   
while($row = mysql_fetch_array($result))
{
?>
<tr>
    <td width="6%" align="center"><input type="radio" name="features" value="<?php echo $row['featured']; ?>" /></td>
    <td width="35%"><?php echo $row['job_title']; ?></td>
    <td width="24%"><?php echo $row['category_name'] ?></td>
    <td width="15%"><?php echo $row['job_location']; ?></td>
    <td width="10%"><?php echo $row['status'] ?></td>
    <td width="10%"><a href="job_edit.php?id=<?php echo $row['job_id']; ?>">Edit</a></td>
</tr>
<?php
}
?>

2 个答案:

答案 0 :(得分:2)

<input type="radio" name="features" value="<?php echo $row['featured']; ?>" 
    <?php echo ($row['featured'] == 1?'checked':'')?>/>

DEMO

答案 1 :(得分:1)

<input type="radio" name="features" value="<?php echo $row['featured']; ?>"
<?php echo $row['featured']?'checked="checked"':'';?>/>