$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();
