pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <legend id='G7t7h'><style id='G7t7h'><dir id='G7t7h'><q id='G7t7h'></q></dir></style></legend>
  • <small id='G7t7h'></small><noframes id='G7t7h'>

    <tfoot id='G7t7h'></tfoot>
    1. <i id='G7t7h'><tr id='G7t7h'><dt id='G7t7h'><q id='G7t7h'><span id='G7t7h'><b id='G7t7h'><form id='G7t7h'><ins id='G7t7h'></ins><ul id='G7t7h'></ul><sub id='G7t7h'></sub></form><legend id='G7t7h'></legend><bdo id='G7t7h'><pre id='G7t7h'><center id='G7t7h'></center></pre></bdo></b><th id='G7t7h'></th></span></q></dt></tr></i><div class="rrztb7j" id='G7t7h'><tfoot id='G7t7h'></tfoot><dl id='G7t7h'><fieldset id='G7t7h'></fieldset></dl></div>
        <bdo id='G7t7h'></bdo><ul id='G7t7h'></ul>

      1. PHP:以五個(gè)為一組顯示數(shù)據(jù)庫中的條目?

        PHP: display entries from Database in groups of five?(PHP:以五個(gè)為一組顯示數(shù)據(jù)庫中的條目?)
            <legend id='zznEl'><style id='zznEl'><dir id='zznEl'><q id='zznEl'></q></dir></style></legend>
            <tfoot id='zznEl'></tfoot>

            <small id='zznEl'></small><noframes id='zznEl'>

              <bdo id='zznEl'></bdo><ul id='zznEl'></ul>

                  <tbody id='zznEl'></tbody>
              1. <i id='zznEl'><tr id='zznEl'><dt id='zznEl'><q id='zznEl'><span id='zznEl'><b id='zznEl'><form id='zznEl'><ins id='zznEl'></ins><ul id='zznEl'></ul><sub id='zznEl'></sub></form><legend id='zznEl'></legend><bdo id='zznEl'><pre id='zznEl'><center id='zznEl'></center></pre></bdo></b><th id='zznEl'></th></span></q></dt></tr></i><div class="75b5vd5" id='zznEl'><tfoot id='zznEl'></tfoot><dl id='zznEl'><fieldset id='zznEl'></fieldset></dl></div>
                • 本文介紹了PHP:以五個(gè)為一組顯示數(shù)據(jù)庫中的條目?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  是否有可能,如果有,我該怎么做,選擇我數(shù)據(jù)庫中一個(gè)表中的所有條目,然后在一組中同時(shí)顯示五個(gè)結(jié)果.

                  含義:例如,我的數(shù)據(jù)庫中總共有 15 條記錄,然后我想像這樣顯示我的數(shù)據(jù):

                  Record[1], Record[2], Record[3], Record[4], Record[5]

                  <div class="6-10">Record[6], Record[7], Record[8], Record[9], Record[10]

                  <div class="11-15">Record[11], Record[12], Record[13], Record[14], Record[15]

                  我不確定是否可以使用 SQL 語句來完成,或者我必須編寫某種do...while"或循環(huán)來檢索每組數(shù)據(jù).我也想過一些關(guān)于數(shù)組的事情,但沒有得到結(jié)果.

                  謝謝

                  • 梅斯蒂卡

                  解決方案

                  我發(fā)現(xiàn) array_chunk() 對這種事情非常有用.

                  //將所有記錄拉入一個(gè)數(shù)組$query = mysql_query('SELECT * FROM mytable');$rows = array();而 ($row = mysql_fetch_array($query)) {$rows[] = $row;}//這將一個(gè)數(shù)組變成一個(gè)數(shù)組數(shù)組,其中每個(gè)子數(shù)組是//5 個(gè)原始條目$groups = array_chunk($rows, 5);//一個(gè)接一個(gè)地處理每一組$開始= 1;foreach ($groups as $group) {$end = $start + 4;//$group 是一組 5 行.按要求處理$content = implode(', ', $group);回聲<<<END<div class="$start-$end">$content</div>結(jié)尾;$開始 += 5;}

                  您當(dāng)然可以不先閱讀所有內(nèi)容而執(zhí)行此操作,但是如果您無論如何都要閱讀所有內(nèi)容,則沒有太大區(qū)別,并且上述版本可能比實(shí)現(xiàn)適當(dāng)?shù)闹袛鄺l件更具可讀性(s) 當(dāng)您從數(shù)據(jù)庫中讀取行時(shí).

                  Is it possible and if so, how can I do it, to select all entries in a table in my database and then display five results at the time in one group.

                  Meaning: A example is that I've 15 records total in my database, then I want to present my data like this:

                  <div class="1-5">Record[1], Record[2], Record[3], Record[4], Record[5]</div>
                  
                  <div class="6-10">Record[6], Record[7], Record[8], Record[9], Record[10]</div>
                  
                  <div class="11-15">Record[11], Record[12], Record[13], Record[14], Record[15]</div>
                  

                  I'm not completely sure if I can do it with an SQL statement or I've to write some sort of "do...while" or loop to retrieve each set of data. I've also thought about something with arrays but haven't got up with a result.

                  Thanks

                  • Mestika

                  解決方案

                  I find array_chunk() to be pretty useful for this kind of thing.

                  // pull all the records into an array
                  $query = mysql_query('SELECT * FROM mytable');
                  $rows = array();
                  while ($row = mysql_fetch_array($query)) {
                    $rows[] = $row;
                  }
                  
                  // this turns an array into an array of arrays where each sub-array is
                  // 5 entries from the original
                  $groups = array_chunk($rows, 5);
                  
                  // process each group one after the other
                  $start = 1;
                  foreach ($groups as $group) {
                    $end = $start + 4;
                  
                    // $group is a group of 5 rows. process as required
                    $content = implode(', ', $group);
                  
                    echo <<<END
                  <div class="$start-$end">$content</div>
                  
                  END;
                    $start += 5;
                  }
                  

                  You can of course do this without reading them all in first but if you're going to read them all anyway, it doesn't make much difference and the above version will probably be far more readable than implementing the appropriate break condition(s) as you read the rows from the DB.

                  這篇關(guān)于PHP:以五個(gè)為一組顯示數(shù)據(jù)庫中的條目?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準(zhǔn)備好的語句amp;foreach 循環(huán))
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個(gè)服務(wù)器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個(gè)參數(shù))
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結(jié)果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“l(fā)ocalhost的訪問被拒絕)

                • <tfoot id='rxNoI'></tfoot>
                      <bdo id='rxNoI'></bdo><ul id='rxNoI'></ul>
                    <legend id='rxNoI'><style id='rxNoI'><dir id='rxNoI'><q id='rxNoI'></q></dir></style></legend>

                      <small id='rxNoI'></small><noframes id='rxNoI'>

                      <i id='rxNoI'><tr id='rxNoI'><dt id='rxNoI'><q id='rxNoI'><span id='rxNoI'><b id='rxNoI'><form id='rxNoI'><ins id='rxNoI'></ins><ul id='rxNoI'></ul><sub id='rxNoI'></sub></form><legend id='rxNoI'></legend><bdo id='rxNoI'><pre id='rxNoI'><center id='rxNoI'></center></pre></bdo></b><th id='rxNoI'></th></span></q></dt></tr></i><div class="r55jhpj" id='rxNoI'><tfoot id='rxNoI'></tfoot><dl id='rxNoI'><fieldset id='rxNoI'></fieldset></dl></div>
                      主站蜘蛛池模板: sfp光模块,高速万兆光模块工厂-性价比更高的光纤模块制造商-武汉恒泰通 | 骨灰存放架|骨灰盒寄存架|骨灰架厂家|智慧殡葬|公墓陵园管理系统|网上祭奠|告别厅智能化-厦门慈愿科技 | 太空舱_民宿太空舱厂家_移动房屋太空舱价格-豪品建筑 | PU树脂_水性聚氨酯树脂_聚氨酯固化剂_聚氨酯树脂厂家_宝景化工 | 诚暄电子公司首页-线路板打样,pcb线路板打样加工制作厂家 | 合肥触摸一体机_触摸查询机厂家_合肥拼接屏-安徽迅博智能科技 | 两头忙,井下装载机,伸缩臂装载机,30装载机/铲车,50装载机/铲车厂家_价格-莱州巨浪机械有限公司 | 冷柜风机-冰柜电机-罩极电机-外转子风机-EC直流电机厂家-杭州金久电器有限公司 | 设定时间记录电子秤-自动累计储存电子秤-昆山巨天仪器设备有限公司 | 天津仓库出租网-天津电商仓库-天津云仓一件代发-【博程云仓】 | 北京翻译公司-专业合同翻译-医学标书翻译收费标准-慕迪灵 | 玉米深加工设备|玉米加工机械|玉米加工设备|玉米深加工机械-河南成立粮油机械有限公司 | 国产液相色谱仪-超高效液相色谱仪厂家-上海伍丰科学仪器有限公司 | 智能汉显全自动量热仪_微机全自动胶质层指数测定仪-鹤壁市科达仪器仪表有限公司 | 全自动烧卖机厂家_饺子机_烧麦机价格_小笼汤包机_宁波江北阜欣食品机械有限公司 | 国际船舶网 - 船厂、船舶、造船、船舶设备、航运及海洋工程等相关行业综合信息平台 | 臻知网大型互动问答社区-你的问题将在这里得到解答!-无锡据风网络科技有限公司 | 运动木地板价格,篮球馆体育运动木地板生产厂家_欧氏地板 | 爱德华真空泵油/罗茨泵维修,爱发科-比其尔产品供应东莞/杭州/上海等全国各地 | 北京乾茂兴业科技发展有限公司| 气动球阀_衬氟蝶阀_调节阀_电动截止阀_上海沃托阀门有限公司 | 自动焊锡机_点胶机_螺丝机-锐驰机器人 | 生产加气砖设备厂家很多,杜甫机械加气砖设备价格公道 | 定时排水阀/排气阀-仪表三通旋塞阀-直角式脉冲电磁阀-永嘉良科阀门有限公司 | 附着力促进剂-尼龙处理剂-PP处理剂-金属附着力处理剂-东莞市炅盛塑胶科技有限公司 | 奥运星-汽车性能网评-提供个性化汽车资讯 | 恒温水槽与水浴锅-上海熙浩实业有限公司 | 【甲方装饰】合肥工装公司-合肥装修设计公司,专业从事安徽办公室、店面、售楼部、餐饮店、厂房装修设计服务 | 地图标注|微信高德百度地图标注|地图标记-做地图[ZuoMap.com] | 广州中央空调回收,二手中央空调回收,旧空调回收,制冷设备回收,冷气机组回收公司-广州益夫制冷设备回收公司 | 机械加工_绞车配件_立式离心机_减速机-洛阳三永机械厂 | 匀胶机旋涂仪-声扫显微镜-工业水浸超声-安赛斯(北京)科技有限公司 | 双舌接地线-PC68数字式高阻计-ZC36|苏海百科 | 好物生环保网、环保论坛 - 环保人的学习交流平台 | 万家财经_财经新闻_在线财经资讯网| 运动木地板价格,篮球馆体育运动木地板生产厂家_欧氏地板 | 安德建奇火花机-阿奇夏米尔慢走丝|高维|发那科-北京杰森柏汇 | 迪威娱乐|迪威娱乐客服|18183620002 | 篷房[仓储-婚庆-展览-活动]生产厂家-江苏正德装配式帐篷有限公司 | 结晶点测定仪-润滑脂滴点测定仪-大连煜烁 | 天津货架厂_穿梭车货架_重型仓储货架_阁楼货架定制-天津钢力仓储货架生产厂家_天津钢力智能仓储装备 |