简体   繁体   English

警报消息无法使用 php

[英]Alert message not working using php

I was trying to code where whenever I hit the submit button it will show an alert message when there's no data fetch.我试图编写代码,每当我点击提交按钮时,它都会在没有数据获取时显示一条警报消息。 Can anyone help me?谁能帮我?

if(isset($_POST['submitEstatus'])) {
 if($_POST['empValue'] == $valEmp AND $_POST['ageValue'] == $valAge AND $_POST['genValue'] == $valGen){ 
    $query = "SELECT * FROM users $valEmp $valAge $valGen"; 
    $result = mysql_query($query);
    if ($result = 0) {
        $message = "No Data";
        echo "<script type='text/javascript'>alert('$message');</script>";
    } else {
        while($row = mysql_fetch_array($result)){
            $lat = $row['lat'];
            $lon = $row['lon'];
            $fname = $row['fname'];
            $address = $row['address'];             
            echo("addMarker($lat, $lon, '<b>$fname</b><br />$address');\n");
            $ageSelected = $valAge;
            $empSelected = $valEmp;
            $genSelected = $valGen;
        }     
    }   
}

I have this error:我有这个错误:

mysql_fetch_array() expects parameter 1 to be resource, integer given in C:\\xampp\\htdocs\\admin\\mapcon.php on line 20 mysql_fetch_array() 期望参数 1 是资源,在C:\\xampp\\htdocs\\admin\\mapcon.php20行给出的整数

On your if statement you are not comparing the value:在您的 if 语句中,您没有比较值:

if ($result = 0) { ....

You are setting 0 to $result .您正在将 0 设置为$result

You should use你应该使用

if ($result == 0) { ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM