久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <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="qwawimqqmiuu" 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:以五個為一組顯示數據庫中的條目?

        PHP: display entries from Database in groups of five?(PHP:以五個為一組顯示數據庫中的條目?)
            <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="qwawimqqmiuu" id='zznEl'><tfoot id='zznEl'></tfoot><dl id='zznEl'><fieldset id='zznEl'></fieldset></dl></div>
                • 本文介紹了PHP:以五個為一組顯示數據庫中的條目?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  是否有可能,如果有,我該怎么做,選擇我數據庫中一個表中的所有條目,然后在一組中同時顯示五個結果.

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

                  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"或循環來檢索每組數據.我也想過一些關于數組的事情,但沒有得到結果.

                  謝謝

                  • 梅斯蒂卡

                  解決方案

                  我發現 array_chunk() 對這種事情非常有用.

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

                  您當然可以不先閱讀所有內容而執行此操作,但是如果您無論如何都要閱讀所有內容,則沒有太大區別,并且上述版本可能比實現適當的中斷條件更具可讀性(s) 當您從數據庫中讀取行時.

                  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.

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

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

                  相關文檔推薦

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

                • <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="qwawimqqmiuu" id='rxNoI'><tfoot id='rxNoI'></tfoot><dl id='rxNoI'><fieldset id='rxNoI'></fieldset></dl></div>
                      主站蜘蛛池模板: 成人视屏在线观看 | 欧美精产国品一二三区 | 国产精品综合色区在线观看 | 久久精品一区 | 手机在线一区二区三区 | 午夜在线免费观看 | 久久精品亚洲 | 天天想天天干 | 亚洲精品久久久久久久不卡四虎 | 国产综合av | 亚洲国产欧美日韩 | 亚洲一区二区在线播放 | 欧美精品一区二区三区一线天视频 | 中文字幕亚洲精品 | 国产精品一区二区av | 国产成人精品高清久久 | 亚洲精品综合 | 精品欧美一区二区三区免费观看 | 亚洲国产视频一区二区 | 一二三四在线视频观看社区 | 久久精品中文字幕 | 一级片av| 日韩欧美精品在线 | 欧美精品久久久久 | 国产伦精品一区二区三区四区视频 | 国产精品a久久久久 | 欧美精品网站 | 亚洲一区二区三区视频 | 日韩成人精品一区二区三区 | 亚洲一区二区三区在线播放 | 精品国产一区二区三区久久 | 中文字幕一区二区三区日韩精品 | 久久6视频 | 亚洲天堂中文字幕 | 精品国产精品三级精品av网址 | 久久精品色欧美aⅴ一区二区 | 超碰成人免费 | 鸳鸯谱在线观看高清 | 一级欧美一级日韩片免费观看 | 精品久久久久久久久久久院品网 | 日韩二区 |