dtgsl60240 2014-02-06 15:11
浏览 107
已采纳

如何在php的select选项中添加复选框?

I make a php page i want to attach check box with list box option value how i attached checkbox,here is my code:

<select name="recepients[]" multiple size="10" multiple="multiple" >
     <?
        //echo $eventid=$_POST['events'];
        $count=count($_POST['events']);
        for($i=0; $i<$count; $i++){
            $select="select b.first_name,b.last_name from buyers b,registrations r where b.buyer_id=r.buyer_id and r.event_id='".$_POST['events'][$i]."' group by r.buyer_id";
            $res = $GLOBALS ['mysqli']->query ($select) or die ($GLOBALS ['mysqli']->error . __LINE__);
            if ($res->num_rows > 0)
            {           
                while($row = $res->fetch_assoc ())
                {
                ?>
                <input type="checkbox" name="receptionts[]" checked="checked"/> 
                <option value="<?=$row['first_name']?>"><?=$row['last_name']?></option>
                <?
                }
            }
        }
        ?>
 </select>
  • 写回答

2条回答 默认 最新

  • dongzhi5587 2014-03-06 11:24
    关注

    I'm not sure I understand the principle of putting a checkbox in a list.
    If this is to select all default item, you may use the lists multipe with the selected option on the option tags

    <select multiple size="10">
    ...
        <option selected="selected" value="<?=$row['first_name']?>"><?=$row['last_name']?></option>
    ....
    

    good luck :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请问读取环境变量文件失败是什么原因?
  • ¥15 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载