Reputation: 512
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
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
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