📅  最后修改于: 2022-03-11 14:54:06.195000             🧑  作者: Mango
connect_error) {
echo "Failed to connect to MySQL: " . $mysqli->connect_error;
}
// Query
$selectQuery = $mysqli->prepare("SELECT * FROM my_table");
$selectQuery->execute();
$selectQueryResult = $selectQuery->get_result();
// Loop
while($selectQueryRow = $selectQueryResult->fetch_array()) {
echo $selectQueryRow['my_column'];
}
// Example
$selectUsername = $mysqli->prepare("SELECT * FROM users");
$selectUsername->execute();
$selectUsernameResult = $selectUsername->get_result();
while($selectUsernameRow = $selectUsernameResult->fetch_array()) {
echo $selectUsernameRow['username'];
}