The page on the server called by the JavaScript is a PHP file calledBook information will be listed here...
GetBook.php, which runs a query against a MySQL database, and returns the result in an HTML table.
When the query is sent from the JavaScript to the PHP file, the following happens:
txtHint placeholder.
<?php
$username = "user_id";
$password = "your-password";
$database = "your-database";
$host = "undcemmysql.mysql.database.azure.com";
$conn = mysqli_init( );
mysqli_ssl_set( $conn, NULL, NULL, "DigiCertGlobalRootCA.crt.pem", NULL, NULL );
mysqli_real_connect( $conn, $host, $username, $password, $database, 3306 );
// Connect to the database.
if ( $conn->connect_errno )
die( 'Failed to connect to MySQL: ' . $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( );
?>
|
|
When choosing sexual partners, Remember: Talent is not transmittable. — Tina Fey |