duanfu4446 2013-03-19 11:18
浏览 92
已采纳

检查查询是否为空或空字符串

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);
            }
        });

    });
  • 写回答

1条回答 默认 最新

  • dpeqsfx5186 2013-03-19 11:41
    关注

    Try something like

    <?php 
        if(!empty($search)) {
    
        }
     ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决