I'm working on a social site something like facebook where when you drag to the bottom of the page, new content will load. Instead, my page will have a more button instead of scrolling. Whenever a user click on the 'more' button, new content will load at the bottom.
My page consist of three different columns. So, what I would like to do is adding 3 new different content to those 3 columns when the 'more' button is clicked.
I would like to return a new div content inside the main column div using ajax and php. Something like this below.
<div class='content_3'>
<div class='widget'>
Content Here
</div>
</div>
Below is an example of my page... Fiddle here http://jsfiddle.net/Lqetw5ck/2/
<div id='main_column_1'>
<div id='content_1'>
Load data from php/mysql database (For 1st Main Div)
</div>
<div id='content_2'>
Load more from php/mysql database when 'more' button is click
</div>
</div>
<br>
<div id='main_column_2'>
<div id='content_1'>
Load data from php/mysql database (For 2nd Main Dev)
</div>
<div id='content_2'>
Load more from php/mysql database when 'more' button is click
</div>
</div>
<br>
<div id='main_column_3'>
<div id='content_1'>
Load data from php/mysql database (For 3rd Main Dev)
</div>
<div id='content_2'>
Load more from php/mysql database when 'more' button is click
</div>
</div>
<button>Show More</button>
And how should I write my PHP code? Because I'm going to return a whole div content. The idea I had is something like this below.
<?
$sql_stmt = SELECT * FROM customers;
$sql = mysqli_query($con, $sql_stmt) or die(mysqli_error($con));
$row = mysqli_fetch_assoc($sql);
$content = '<div class=content_3><div class=widget> '.$row['firstname'].' </div></div>';
?>
I want to return the $content string back to the main column 1,2 and 3 so it will display a new div under that column.
Thanks!
EDIT: I found this How to implement jScroll? but don't know how the author wrote his PHP code. Maybe this is almost the same as my case?