使用MySQLi的准系统示例:
// connect to your database
$mysqli = new mysqli("hostname", "username", "password", "database");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
// setup your query
$query = "SELECT * FROM engineering ";
$results = array();
// execute your query
if ($result = $mysqli->query($query)) {
// the query was successful; iterate through each result fetching an
// associative array and add it to the `$results` list
while ($row = $result->fetch_assoc()) {
$results[] = $row;
}
$result->free();
}
$mysqli->close();
// process all results in `$results` array! (simple output)
foreach ($results as $result) {
echo $result['id'] . ' ' . $result['engineering'] . '<br />';
}