I created a simple searching function in php. Its working when im not using ajax to that script. But when i use ajax, my implode function disappear.
Here how my codes looks like.
$searchtag = filter_var($_GET['search'], FILTER_SANITIZE_STRING);
$searchtagrlce = str_replace("+", " ", $searchtag);
$searchTermsis = explode(' ', $searchtagrlce);
$searchTermBitsis = array();
foreach ($searchTermsis as $terms) {
$terms = trim($terms);
if (!empty($terms)) {
$searchTermBitsis[] = "tbale_row1 LIKE '%$terms%' OR tbale_row12 LIKE '%$terms%' OR tbale_row13 LIKE '%$terms%'";
}
}
$getdataquerystores = "SELECT `tbale_row1`, `tbale_row2`, `tbale_row3`, `tbale_row4`, `tbale_row5`, `tbale_row6` FROM `tablename` WHERE ".implode(' AND ', $searchTermBitsis). " ORDER BY tbale_row1 DESC LIMIT $limit, 10";
$getdataquerystoress = mysqli_query($connection, $getdataquerystores);
when i echo or print the above codes without ajax, im getting this
SELECT `tbale_row1`, `tbale_row2`, `tbale_row3`, `tbale_row4`, `tbale_row5`, `tbale_row5` FROM `tablename` WHERE tbale_row1 LIKE '%a%' OR tbale_row2 LIKE '%a%' OR tbale_row3 LIKE '%a%' ORDER BY tbale_row1 DESC LIMIT 0, 10
but when i use ajax and print the above same code, im getting this (AFTER WHERE FUNCTION DATA HAS BEEN DISAPPEAR)
SELECT `tbale_row1`, `tbale_row2`, `tbale_row3`, `Logo_croped_554`, `tbale_row5, `tbale_row6` FROM `tablename` WHERE ORDER BY tbale_row1 DESC LIMIT 10, 10
here it is my ajax code
$(window).scroll(function ()
{
if($(document).height() <= $(window).scrollTop() + $(window).height())
{
loadmore();
}
});
function loadmore()
{
var val = $("#row_no").val();
$.ajax({
type: 'post',
url: '/myproject/data/alldata.php',
data: {
getresult:val
},
beforeSend:function(){
$(".loading-data").fadeIn("slow");
},
uploadProgress:function(){
$(".loading-data").fadeIn("slow");
},
success: function (response) {
var content = document.getElementById("dsdplasdy_sdtres");
content.innerHTML = content.innerHTML+response;
document.getElementById("row_no").value = Number(val)+10;
},
complete:function() {
$(".loading-data").fadeOut("slow");
}
});
}
here it is the value im getting from tne hidden field
<input type="hidden" id="row_no" value="10" />
Please any ex[ert may help me. Any help much appreciated. Thanks.