doumeng3345 2014-07-03 15:35
浏览 28

从用户视图中隐藏div

I want to return true when the number of rows in a table is more than one and show a div with jquery as shown in the jquery code .In addition return false when the number of rows is zero and hide a div as shown in the code below.The php code is executing and returning a correct value but the jquery code is neither showing or hiding a div.I need to show a div when the value returned is true and hide a div when the value returned is false;

**php code** php code for retrieving the number of rows from a table


<?php
    require'php/connection.php';//a file for connecting to the database
    $user_name=getUserField('user_name');//function for getting the name of the user in session

    $query="select `order_id` from `inbox` where `buyer_name`='$user_name'";
    $query_run=mysql_query($query);
    $num_rows=mysql_num_rows($query_run);
    if($num_rows >= 1) {
        return true;
    } else if($num_rows == 0) {
        return false;
    }
?>

jquery code Jquery code for either hiding or showing a div

$(document).ready(function() {
    $.post('php/ManNotify.php',{},function(data){
        if(true) {
            $('#notify').show();
        } else if(false) {
            $('#notify').hide();
        }
    });
});
  • 写回答

5条回答 默认 最新

  • duanlu1922 2014-07-03 15:39
    关注

    Do you realize your if statement reads,

    if(true) ..
    else if(false) ...
    

    The hide will never execute. Is this your problem?

    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用