I am working on a search function on my website and i am onto doing a next and previous feature, displaying 16 results per page. I have to check if my query isnt null or an empty string however i am no good at if statements as such and i am guessing i have to do one? I am using AJAX for the click functions of next and previous but doing all the calculations in PHP. I guess to do this first query, i have to use an if statement? This is what i have so far.. I don't know which query to check for that is null or an empty string.
This is the function i am working on. I am looking to create an if statement to check if query isnt null but unsure how? Any help would be greatly appreciated:
public function keywordAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(TRUE);
$session = new Zend_Session_Namespace("keyword");
$search = "";
if(isset($session->search)) {
$search = $session->search;
}
if {
}
}
This is the AJAX code i have for the function:
$(".paginator").click(function(){
var action = $(this).attr("action");
var page = $("#pageNo").val();
var pageint = parseInt(page);
var request = $.ajax({
url : "/support/keyword/",
dataType : "JSON",
type : "POST",
data : {
action : action,
page : pageint,
itemsperpage : parseInt($("#itemsperpage").val())
}
});
request.done(function(response){
if(response.error != undefined) {
window.location = "/";
}
if(response.results != undefined) {
$("#output").html(response.results);
}
if(response.disable != undefined) {
if(/1/i.test(response.disable)) {
$(this).hide();
}
}
if(response.undisable != undefined) {
if(/1/i.test(response.undisable)) {
if(/next/i.test(action)) {
$("#previous").show();
} else {
$("#next").show();
}
}
}
if(response.resultsstring != undefined) {
$("#resultsstring").html(response.resultsstring);
}
});
});