Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to display query results in sets, increment on user click php?
    primarykey
    data
    text
    <p>Hi im a complete newbie and this may seem very simple to any experienced user.</p> <p>So what i am trying to achieve is, i have box that is going to hold recent feedback i receive from clients. The box is to display 6 results from a mysql database query. The box also has a more and previous button. When the user clicks more the results must cycle to the next 6 comments, if none exist then nothing happens. If a user clicks the prev button it must go to the prev 6 comments, disabled on first set. I want to be able to do this on the fly using ajax so no page reload must happen.</p> <p>Would i have to use pagination, to accomplish such a small task and set of comments? If so how do i go about setting it up?</p> <p>ATM i am able to display the first 6 results of what i want, but do not know how to continue. Here is the php and html. Any hints for the direction i should be going in are welcome. </p> <pre><code>$link = mysqli_connect('localhost','root','password','database'); if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later'; exit;} $db = mysqli_select_db($link, "database"); $query = "SELECT * FROM clients, orders WHERE clients.ID = orders.ID ORDER BY Date DESC LIMIT 0,6"; $result = mysqli_query($link,$query); &lt;div class="sidebar"&gt; &lt;div class="clientwrapper"&gt; &lt;h2&gt;Client Feedback&lt;/h2&gt; &lt;div class="box"&gt; while($row=mysqli_fetch_array($result)){ echo '&lt;p&gt; '.$row["Comments"].' &lt;span class="name"&gt; By '.$row["Organisation"].' &lt;/span&gt; &lt;/p&gt;'; &lt;a class="nodecoration" href="" &gt;&lt;span class="next-button"&gt;More&lt;/span&gt;&lt;/a&gt; &lt;a class="nodecoration" href="" &gt;&lt;span class="prev-button"&gt;&lt;/span&gt;&lt;/a&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
    singulars
    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.
    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