dpd7195 2013-08-29 17:33
浏览 26

当我在php中动态创建它们时,如何并排对齐复选框?

I m trying to create a form with multiple checkboxes. The checkboxes are dynamically created from a database but they are always created in a new line while I want them to be aligned side by side. I am new to CSS and php/mysql so I m unable to get it right. Can you help me out?

$mysqli = new mysqli('localhost', 'mechuser', 'mypassword', 'mechug_lab');

$query = "SELECT * FROM slots WHERE lab_id = '530_335' AND slot_status = '0' AND expt_id='3'";
$result=mysql_query($query);

if($result) {
                if(mysql_num_rows($result) != 0) {
                    $date = "0000-00-00";
                    while($row = mysql_fetch_array($result)):
                    ?>
                    <div><label><?php
                    $date1 = $row['date'];
                    $weekday = date('D', strtotime($date1));
                    $today = date('M j, Y',strtotime($date1));
                    if ($date1 != $date)
                        echo "<strong>".$today."   ".$weekday."</strong> &nbsp";
                        echo " ".$row['slot_time'];
                        $date = $date1;
                    ?>
                    <input type="checkbox" name="bookings[]" value="1"></label></div><?php endwhile;
                    }
                    }
                    ?>

  • 写回答

3条回答 默认 最新

  • duanbimo7212 2013-08-29 17:36
    关注

    The div around your checkboxes are block level elements (which makes new lines), you may want to use span (which is an inline level element) instead or make the inline / inline-block elements or float them, the choice is yours :)

    style="display:inline" or style="display:inline-block" or <span> instead of <div>

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测