php通过mysqli接口检索和显示数据的代码
$mydb = new mysqli('localhost', 'username', 'password', 'databasename'); $sql = "SELECT * FROM users ORDER BY lname, fname"; $result = $mydb->query($sql); while( $row = $result->fetch_assoc() ){ echo $row['fname'] . " " . $row['lname'] ; echo " made these comments: " . substr($row['comments'],0,150) ; echo "<br/>"; } $mydb->close ();