By Anthony T. Holdener III
Book Price: $49.99 USD
£30.99 GBP
PDF Price: $39.99
Cover | Table of Contents | Colophon
Gecko | Trident | KHTML/WebCore | Presto | |
|---|---|---|---|---|
HTML | Yes | Yes | Yes | Yes |
XHTML/XML | Yes | Partial | Partial | Yes |
CSS1 | Yes | Yes | Yes | Yes |
CSS2 (CSS2.1) | Yes | Partial | Yes | Yes |
CSS3 | Partial | No | Partial | Partial |
DOM Level 1 | Yes | Partial | Yes | Yes |
DOM Level 2 | Yes | No | Yes | Yes |
DOM Level 3 | Partial | No | Partial | Partial |
RSS | Yes | No | Yes | Yes |
Atom | Yes | No | Yes | Yes |
JavaScript | 1.7 | 1.5 | 1.5 | 1.5 |
PNG alpha-transparency | Yes | Yes | Yes | Yes |
XSLT | Yes | Yes | No | Yes |
SVG | Partial | No | Partial | Partial |
XPath | Yes | Yes | No | Yes |
Ajax | Yes | Yes | Yes | Yes |
Progressive JPEG | Yes | No | Yes | Yes |
Basic authentication | https | Virtual hosting | CGI | FastCGI | Servlet | SSI | |
|---|---|---|---|---|---|---|---|
Apache HTTP Server | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
IIS | Yes | Yes | Yes | Yes | No | No | Yes |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html401/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<TITLE>Example 3-1. A typical server response to a form submit.</TITLE>
</HEAD>
<BODY BGCOLOR="WHITE">
<H1>Query Results</H1>
<TABLE>
<TR><TH>Book Name</TH></TR>
<?php
require('db.inc');
if (!($conn = @mysql_connect($host, $username, $password)))
die('Could not connect to the database.');
$author = mysql_real_escape_string(isset($_POST['authorName']) ?
$_POST['authorName'] : '');
if (!@mysql_select_db($db, $conn))
die('Could not select database.');
$sql = 'SELECT book_id, book_nm FROM books, authors WHERE books.author_id '
.'= authors.author_id';
if (isset($author))
$sql .= " AND authors.author_nm = $author'";
$sql .= ' ORDER BY book_nm';
if ($result = @mysql_query($sql, $conn)) {
while ($row = @mysql_fetch_assoc($result)) {
?>
<TR><TD><?= $row['book_nm']; ?></TD></TR>
<?php
}
mysql_free_result($result);
mysql_close($conn);
} else {
?>
<TR><TD>There were no results for the specified query.</TD></TR>
<?php
}
?>
</TABLE>
</BODY>
</HTML>
<?php
/**
* Revisiting Example 3-2.
*/
/**
* The generic db.php library, containing database connection information such as
* username, password, server, etc., is required for this example.
*/
require('db.inc');
/* Output the XML Prolog so the client can recognize this as XML */
$xml = <<< PROLOG
<?xml version="1.0" encoding="iso-8859-1"?>
PROLOG;
/* Is there a connection to the database server? */
if (!($conn = @mysql_connect($host, $username, $password)))
$xml .= '<error>Could not connect to the database.</error>';
$author = mysql_real_escape_string(isset($_POST['authorName']) ?
$_POST['authorName'] : '');
/* Could the database be selected? */
if (!@mysql_select_db($db, $conn))
$xml .= '<error>Could not select database.</error>';
$sql = 'SELECT book_id, book_nm FROM books, authors WHERE books.author_id '
.'= authors.author_id';
/* Was the parameter /authorName/ passed to this script? */
if (isset($author))
$sql .= " AND authors.author_nm = '$author'";
$sql .= ' ORDER BY book_nm';
/* Are there results from the query? */
if ($result = @mysql_query($sql, $conn)) {
$xml .= '<results>';
/* Loop through the records
while ($row = @mysql_fetch_assoc($result))
$xml .= "<result>{$row['book_nm']}</result>";
/* Were there any records to loop through? */
if (!@mysql_num_rows($result))
$xml .= '<result>There were no results for the specified query.</result>';
$xml .= '</results>';
/* Free the mysql result */
mysql_free_result($result);
mysql_close($conn);
} else
$xml .= '<results>'
.'<result>There were no results for the specified query.</result>'
.'</results>';
/*
* Change the header to text/xml so that the client can use the return
* string as XML
*/
header("Content-Type: text/xml");
echo $xml;
?>
XMLHttpRequest object. This object allows for asynchronous communication between the client and the server. In other words, the client can start communicating with the server, and instead of the client freezing up and becoming unusable until that communication is complete, the client can continue to function like normal.XMLHttpRequest object is implemented is different from one browser to the next. For Safari, Mozilla, Opera, and other like-minded browsers, you create the object like this:var request = new XMLHttpRequest( );
var request = new ActiveXObject('Microsoft.XMLHTTP');
XMLHttpRequest object or the ActiveX version, the object has the same basic methods and properties associated with it, as shown in and .XMLHttpRequest object. This object allows for asynchronous communication between the client and the server. In other words, the client can start communicating with the server, and instead of the client freezing up and becoming unusable until that communication is complete, the client can continue to function like normal.XMLHttpRequest object is implemented is different from one browser to the next. For Safari, Mozilla, Opera, and other like-minded browsers, you create the object like this:var request = new XMLHttpRequest( );
var request = new ActiveXObject('Microsoft.XMLHTTP');
XMLHttpRequest object or the ActiveX version, the object has the same basic methods and properties associated with it, as shown in and .Property | Description |
|---|---|
onreadystatechange | The function assigned to this property, which is an event listener, is called whenever the readyState of the object changes. |
readyState | This property represents the current state that the object is in. It is an integer that takes one of the following:
|