<?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/> "; $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/> "; $conn->close(); exit; } $conn->close();