Note that there are some explanatory texts on larger screens.

plurals
  1. POlimit number of fetched results per category to only 4 than display "See More Results"
    primarykey
    data
    text
    <p>running into a problem yet again and need some help with solving it.</p> <p>I need to limit the number of retrieved results in each category that has any results at all to display only 4 and below category will be displaying link to the category such as "See more Results" or similar.</p> <p>My initial thought was that I need to either change or add something to the actual query it self so I did add LIMIT 4, but the outcome of this was that I ended up with only one category being displayed with 4 items within that category and this was it.</p> <p>Please help</p> <p>here is my script</p> <pre><code>if($category_type == 'links_only'){ $category_topic_query = 'SELECT l.category_name, l.category_folder, l.category_page, f.parentpageID, f.ImagePath, f.referring_url, f.templateTitle, f.xls, f.xlsx, f.ots, f.gdocs, f.numbers, f.templateImage, f.templimgwidth, f.templimgheight FROM lcategories l INNER JOIN Files f ON f.parentpageID = l.ID WHERE f.pageID = "0" ORDER BY f.parentpageID'; $resc = $db-&gt;prepare($category_topic_query); $resc-&gt;execute(); $last_topic = NULL; $add_rowNum = 1; while ($category_topic = $resc -&gt; fetch()){ $category_topic_ID = $category_topic['parentpageID']; if($category_topic_ID !== $last_topic) { $add_rowNum++; $category_topic_name = str_replace("&amp;", "&amp;amp;", $category_topic['category_name']); $category_topic_url = DST.$category_topic['category_folder'].DS.$category_topic['category_page']; $divider_div = ($add_rowNum % 2 == 0) ? ' &lt;div class="clear"&gt;&lt;/div&gt;' : FALSE ; $first_ul = ($category_topic_ID == 1) ? FALSE : '&lt;/ul&gt; &lt;/div&gt;'.$divider_div ; print&lt;&lt;&lt;END $first_ul &lt;div style="float: left; margin: 10px; width: 349px;"&gt; &lt;h2 class="h_unln"&gt;&lt;a href="$category_topic_url"&gt;$category_topic_name&lt;/a&gt;&lt;/h2&gt; &lt;ul class="arrow"&gt; END; $last_topic = $category_topic_ID; } $links_array = ($category_topic['referring_url'] == NULL) ? FALSE :' &lt;li&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="'.DST.$category_topic['ImagePath'].DS.$category_topic['referring_url'].'"&gt;&lt;img src="'.$image_path.$category_topic['ImagePath'].DS.$category_topic['templateImage'].'" width="'.$category_topic['templimgwidth'].'" height="'.$category_topic['templimgheight'].'" title="'.$category_topic['templateTitle'].'"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="'.DST.$category_topic['ImagePath'].DS.$category_topic['referring_url'].'"&gt;'.$category_topic['templateTitle'].'&lt;/a&gt;&lt;/li&gt; &lt;li&gt;'.$numbers_im.$gdocs_im.$ots_im.$xlsx_im.$xls_im.'&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;'; print&lt;&lt;&lt;END $links_array END; } print&lt;&lt;&lt;END &lt;/ul&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; END; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload