开发者

how to display query results in sets, increment on user click php?

Hi im a complete newbie and this may seem very simple to any experienced user.

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.

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?

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.

$link = mysqli_co开发者_开发百科nnect('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);

<div class="sidebar">

          <div class="clientwrapper">

          <h2>Client Feedback</h2>

               <div class="box">

                      while($row=mysqli_fetch_array($result)){

                   echo '<p> '.$row["Comments"].' <span class="name"> By  '.$row["Organisation"].' </span> </p>';

            <a class="nodecoration" href="" ><span class="next-button">More</span></a>

            <a class="nodecoration" href="" ><span class="prev-button"></span></a>

<div class="clear"></div>

</div>

</div>


The easy answer is use an iframe and reload the page in the iframe. The hard answer, learn about AJAX.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜