无法从sql获取数据

时间:2016-04-21 09:11:05

标签: php html mysql

我正在尝试为移动修复管理制作网络应用程序到目前为止我已经将数据提交给MySQL但是每当我尝试检索数据时都显示空白页面或者它给出了MySQL_num_rows()期望参数1是资源错误

这是我的代码

<?php
   $connect = mysqli_connect('localhost','root','password','shopdata');
   if(mysqli_connect_errno($connect)){
echo 'FAILED';
 }
?>

<?php
  $result = mysqli_query($connect,"SELECT * FROM `jobsheets` ");
 ?>

<table width="1350" cellpadding=5 cellspacing=5 border=1>
<tr>
    <th>JOBSHEET NO.</th>
    <th>CUSTOMER NAME</th>
    <th>CUSTOMERS PH.</th>
    <th>MOBILE BRAND</th>
    <th>MODEL NAME</th>
    <th>IMEI NO.</th>
    <th>FAULT</th>
    <th>BATEERY</th>
    <th>BACKPANEL</th>
    <th>CONDITION</th
</tr>
<?php
If (mysql_num_rows($result) > 0) {
    while ($row = mysql_fetch_array($result)) {
?>
    <tr>
        <td><?php echo $row['job_number']; ?></td>
        <td><?php echo $row['cust_name']; ?></td>
        <td><?php echo $row['cust_mob']; ?></td>
        <td><?php echo $row['mob_brand']; ?></td>
        <td><?php echo $row['mob_name']; ?></td>
        <td><?php echo $row['imei_number']; ?></td>
        <td><?php echo $row['fault_name']; ?></td>
        <td><?php echo $row['bat_status']; ?></td>
        <td><?php echo $row['panel_status']; ?></td>
        <td><?php echo $row['misc_note']; ?></td>
    </tr>

   </table>
   <?php
     }
   }
   ?>**strong text**

1 个答案:

答案 0 :(得分:-1)

您无法组合mysql_和mysqli_函数。任何以mysql_开头的东西现在都被正式弃用,所以你应该转向使用mysqli_或理想的PDO。

http://php.net/manual/en/book.mysqli.php

http://php.net/manual/en/book.pdo.php