<?php
$username = "user.id@undcsmysql";
$password = "your-password";
$database = "your-database";
$host = "undcsmysql.mysql.database.azure.com";
// Connect to the database.
$conn = new mysqli( $host, $username, $password, $database );
if ( $conn->connect_error )
die( 'Could not connect: ' . $conn->connect_error );
// Print the table header.
echo "<center><table border='1'><tr>
<th>ISBN</th>
<th>Title</th>
<th>Price</th></tr>";
// Compose and execute a query.
$q = $_GET["q"];
$sql = "select * from bookList where ISBN = '" . $q . "'";
$result = $conn->query( $sql );
// Print the results row by row.
if ( $result->num_rows > 0 ) {
while ( $row = $result->fetch_assoc( ) ) {
echo "<tr><td>" . $row['ISBN'] . "</td>";
echo "<td>" . $row['title'] . "</td>";
echo "<td>" . $row['price'] . "</td></tr>";
}
}
echo "</table></center>";
// Close the database connection.
$conn->close( );
?>
|