<?php
require('./kwd.php');
$conn=@new mysqli('localhost','root',$kwd,'mytestdb');
if($conn===false){
    $errno=mysqli_connect_errno();
    $errmsg=mysqli_connect_error();
    echo "连接出错:($errno)$errmsg<br/>\n";
    $conn->close();
    exit;
}
$que="select*from users";
$result=$conn->query($que);
if($result){
    echo<<<EOM
    <table>
    <tr>  
    <td>id</td>
    <td>name</td>
    <td>email</td>
    <td>datetime</td>
    </tr>
EOM;
     while (($row_data=@$result->fetch_assoc())!==null) {
         echo <<<EOM
    <tr>
    <td>{$row_data['id']}</td>
    <td>{$row_data['name']}</td>
    <td>{$row_data['email']}</td>
    <td>{$row_data['date']}</td>
    </tr>
EOM;
}
 echo<<<TAB
    </table>
TAB;
$result->close();
}else{
     $errno=$conn->errno;
     $errmsg=$conn->error;
     echo "出错了:($errno)$errmsg<br/>\n";
     $conn->close();
     exit;
}
$conn->close();

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-30
  • 2021-07-10
  • 2021-07-13
  • 2022-01-19
  • 2022-01-11
  • 2021-07-10
相关资源
相似解决方案