$mysqli = mysqli_init(); $mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 2);//设置超时时间,以秒为单位的连接超时时间 $mysqli->real_connect'dbUrl', 'dbRoot', 'password', 'database'); $mysqli->set_charset("utf8"); $sql1 = "SELECT * FROM dbTable"; $result = $mysqli->query($sql1); if($result === false) { die('!数据库连接失败:(' . $mysqli->connect_errno . ') '. $mysqli->connect_error); } while($row=$result->fetch_row()){ ?> <table> <tr> <td><?php echo $row[0].$row[1].$row[2] ?></td> </tr> </table> <?php } $result->close();