<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* Vérifie la connexion */
if (mysqli_connect_errno()) {
printf("Échec de la connexion : %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 150,5";
if ($stmt = mysqli_prepare($link, $query)) {
/* Exécution de la requête */
mysqli_stmt_execute($stmt);
/* Association des variables de résultat */
mysqli_stmt_bind_result($stmt, $name, $code);
/* Lecture des valeurs */
while (mysqli_stmt_fetch($stmt)) {
printf ("%s (%s)\n", $name, $code);
}
/* Fermeture de la commande */
mysqli_stmt_close($stmt);
}
/* Fermeture de la connexion */
mysqli_close($link);
?>
Les exemples ci-dessus vont afficher :
Rockford (USA)
Tallahassee (USA)
Salinas (USA)
Santa Clarita (USA)
Springfield (USA)