pedrum golriz
pedrum golriz

Reputation: 512

Load more rows from database on click without page refresh

I am trying to have my loop stop at 5 rows by default, but when the button is clicked it would load more. Are there any simple solutions for this? I don't want the page to refresh either.

My code below:

<?php
$count = 0;
while (($row = mysql_fetch_assoc($thequery)))  {
    echo $row['title'];
    $count+=1;
    if($count%5==0){
        break 1;
    }
}
?>
<span onClick="loadmore_somehow">Load More</span>

Upvotes: 0

Views: 290

Answers (2)

Praveen Govind
Praveen Govind

Reputation: 5627

I think you need to know more about Javascript Ajax, It will help you do update,retrieve the content without refreshing page.

Check out this tutorial http://www.developphp.com/view.php?tid=1350

Upvotes: 0

Machavity
Machavity

Reputation: 31614

An AJAX call would do that. Using Javascript (and preferably a library like jQuery) you would make a call to your script and get more rows, pass them back, and then use Javascript to draw the rows. This does not reload the page.

http://api.jquery.com/category/ajax/

Upvotes: 2

Related Questions