选择查询不起作用

时间:2015-12-03 10:55:42

标签: php

  

警告:mysql_num_rows()期望参数1是资源,E:\xampp\htdocs\php\oop\codingcage_one\index.php中给出的布尔值   Image

    <table align="center">
    <tr>
    <th colspan="5"><a href="insert-update.php">add data here.</a></th>
    </tr>
    <th>First Name</th>
    <th>Last Name</th>
    <th>City Name</th>
    <th colspan="2">Operations</th>
    </tr>
    <?php

        $res = $con->getdata("SELECT * FROM users ");
        if (mysql_num_rows($res) == 0)
        {

    ?>
    <tr>
    <td colspan="5">Nothing Found Here !</td>
    </tr>
    <?php
        }
        else
        {
            while($row =  mysql_fetch_array($res))
            {
  ?>
        <tr>
        <td><?php echo $row['first_name'];  ?></td>
        <td><?php echo $row['last_name'];  ?></td>
        <td><?php echo $row['user_city'];  ?></td>
        <td align="center"><a href="javascript:edt_id('<?php  ?>')"><img src="b_edit.png" alt="EDIT" /></a></td>
        <td align="center"><a href="javascript:delete_id('<?php  ?>')"><img src="b_drop.png" alt="DELETE" /></a></td>
        </tr>
        <?php
            }
        }
?>
    </table>

1 个答案:

答案 0 :(得分:0)

 $res = $con->getdata("SELECT * FROM users ");

替换为:

  $res = mysql_query("SELECT * FROM users ");