简体   繁体   English

PHP查询没有结果

[英]php query no result

    <?php include 'db.php';

    $GLOBALS["conn"] = conncet();

    if (isset($_POST['submit'])) {
        $ime = $_POST['ime'];
        $rm = $_POST['rm'];
        $minpl = $_POST['minpl'];
        $maxpl = $_POST['maxpl'];

        $query = "select * from zaposleni where ime = '{$ime}' and radno_mesto = '{$rm}' and plata between '{$minpl}' and '{$minpl}'";
        $result = mysqli_query($GLOBALS["conn"], $query);

        if (!$result) {
            echo "Query failed" . mysqli_error($GLOBALS["conn"]);
        }

        $count = mysqli_num_rows($result);

            if ($count == 0) {
                echo "NO RESULT";
            } else { 

        while($row = mysqli_fetch_assoc($result)) {
            $i = $row['ime'];
            $r = $row['radno_mesto'];
            $p = $row['plata'];

                ?>

                <table>
        <thead>
            <tr>
                <th>Ime:</th>
                <th>Radno mesto:</th>
                <th>Plata:</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><?php echo $i; ?></td>
                <td><?php echo $r; ?></td>
                <td><?php echo $p; ?></td>
            </tr>
        </tbody>
    </table>


                <?php
            } }
        if ($ime == "" || $rm = "" || $minpl = "" || $maxpl = "") {
            echo "Morate uneti sva polja";
        }

            }


    ?> 


    <form action="" method="post">
        <div class="form-group">
            <label for="ime">Ime:</label>
            <input type="text" class="form-control" name="ime">
        </div>

        <div class="form-group">
            <label for="rm">Radno mesto:</label>
            <input type="text" class="form-control" name="rm">
        </div>

        <div class="form-group">
            <label for="minpl">MIN Plata:</label>
            <input type="text" class="form-control" name="minpl">
        </div>

        <div class="form-group">
            <label for="maxpl">MAX Plata:</label>
            <input type="text" class="form-control" name="maxpl">
        </div>

        <input type="submit" name="submit" value="Pretraga">
    </form>

it says no result, despite full database. 它说没有结果,尽管数据库完整。 Why is it not working? 为什么不起作用? Any suggestions for this problem? 对这个问题有什么建议吗? It has no syntax errors. 它没有语法错误。 Maybe query? 也许查询?

https://files.fm/u/dgamw5uu#/view/Stack.PNG this is the link of database. https://files.fm/u/dgamw5uu#/view/Stack.PNG这是数据库的链接。

PS Name of a function conncet() is not a error, just a misspelling in a function name. PS函数conncet()的名称不是错误,只是函数名称中的拼写错误。

ime means name, radno_mesto means work place min plata means minimal salary max plata means maximal salary ime表示姓名,radno_mesto表示工作地点min plata表示最低工资max plata表示最高工资

I would try this as syntax for your query : (you used minpl twice) 我会尝试将其作为您查询的语法:(您两次使用minpl)

 $query = "select * from zaposleni where ime = '".$ime."' and radno_mesto = '".$rm."' and plata between ".$minpl." and ".$maxpl ;

and make the correct value are posted for $ime, $rm, $minpl adn $maxpl 并为$ ime,$ rm,$ minpl和$ maxpl发布正确的值

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

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