<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if ($stmt = mysqli_prepare($link, "SELECT Code, Name FROM Country ORDER BY Name LIMIT 5")) {
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $col1, $col2);
while (mysqli_stmt_fetch($stmt)) {
printf("%s %s\n", $col1, $col2);
}
mysqli_stmt_close($stmt);
}
mysqli_close($link);
?>