通过无线电检查更新和删除

时间:2011-08-09 18:18:01

标签: php mysql phpmyadmin mysqli

我有一张桌子,我正在使用一个项目,其中值= 1 其余的值= 0

这是清单

    <table cellspacing="0" cellpadding="0">
<form action="" method="POST">

<tr>
    <th width="6%" >Featured</th>
    <th width="35%">Job Title</th>
    <th width="24%">Category</th>
    <th width="15%">Location</th>
    <th width="10%">Status</th>
    <th width="10%">Action</th>
</tr>
<?php   
while($row = mysql_fetch_array($result))
{
?>
<tr>
    <td width="6%" align="center">
        <input type="radio" name="featured" value="<?php echo $row['job_id']; ?>" 
        <?php echo ($row['featured'] == 1?'checked':'')?>/>
    </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
}
?>
</tr>
<tr class="box_foot">

    <td colspan='6'><div class="save_b"><input type="submit" class="button_save buttons" name="submit" value="Continue"></div></td>
</form>
</table>
</div>

当我选择需要显示的值= 1时 其余的必须在表格中显示= 0

1 个答案:

答案 0 :(得分:2)

只有一个项目,我应该使用$ already_featured变量,如下所示:

<?php   
$already_featured = FALSE;
while($row = mysql_fetch_array($result))
{
?>
<tr>
    <td width="6%" align="center">
        <input type="radio" name="featured" value="<?php echo $row['job_id']; ?>" 
        <?php if ($row['featured'] == 1 AND !$already_featured) {echo 'checked'; $already_featured = TRUE;} ?>/>