drhzn3911 2014-05-13 16:38
浏览 42

php mysql每个循环限制10个结果

i have a dropdown where there are three columns and each column contains 10 results from db i want to get first 10 result for first column, then get another 10 result for second column and so on. following is my code which generate three column but each column has all the result

<div class="mega-menu">
            <?php
                $query = mysql_query("select * from product where pid = 0 and status=1") or die(mysql_error());
                $total_rows = ceil(mysql_num_rows($query)/10);
                for($i=1; $i<=$total_rows; $i++)
                {
            ?>
              <div class="col-1">
                <ol>
                    <?php
                        $first_result = mysql_query("select * from product where pid = 0 and status=1 limit 10 offset 10") or die(mysql_error());
                        if(mysql_num_rows($first_result) > 0)
                        { 
                            while($first_row = mysql_fetch_array($first_result)) { 
                    ?>
                    <li><a href="<?=base_url().$first_row['product_slug']?>"><?=$first_row['product_name']?></a></li>
                    <?php } }?>
                </ol>
              </div>
              <?php  } ?>
        </div>

i know i am doing mistake in first result query

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 stata安慰剂检验作图但是真实值不出现在图上
    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题