I am trying to get all the items that are loaded (after clicking load more) to be sorted out according to the filter settings that were submitted before hand. I have all the settings being displayed on the url as the form is submitted with GET
For some reason, I cannot retrieve the settings from the url using GET after the form is submitted and load more is clicked.. any idea why?
This query sorts out all the results:
<div class="main_page">
<?php
$res = mysql_query("SELECT * FROM posts WHERE ".$search_query." ".$lowest_price." ".$highest_price." ".$ad_order." ".$limit."");
if($res && mysql_num_rows($res) > 0){
while($row = mysql_fetch_assoc($res)){
$date = $row['date'];
}
echo '<div class="ad_display" id="'.$date.'">blabla</div>';
}
In the loadmore.php, there is the exact same div but it is sorted out like so:
$res = mysql_query("SELECT * FROM posts WHERE `date` < '".mysql_real_escape_string($_GET['id'])."' ORDER BY `date` DESC LIMIT 10");
and of course the load more button script:
<script type="text/javascript">
$(document).ready(function(){
$(".load_more").click(function (){
$('.load_more').html('<img src="images/ajax-loader.gif" />');
$.ajax({
url: "loadmore.php?id=" + $(".ad_display:last").attr("id"),
success: function(html){
if(html){
$(".main_page").append(html);
$('.load_more').html('Load More');
}else{
$('.load_more').replaceWith('No more posts');
}
}
});
});
});
</script>
<button class="load_more">Load More</button>
Any help is much appreciated!
UPDATE:
if(isset($_GET['search'])){
$searchq = $_GET['search'];
$searchq = sanitize(preg_replace("#[^0-9a-z]#i","",$searchq));
$search_query = "AND (title LIKE '%".$searchq."%' OR description LIKE '%".$searchq."%')";
}