
<PEOPLE>DTD is a data type definition. It defines an application specific special case of XML.
<PERSON>
<NAME>Mark Wilson</NAME>
<TEL>(619) 543 12345</TEL>
<AGE>23</AGE>
</PERSON>
<PERSON>
<NAME>Tracey Wilson</NAME>
<TEL>(858) 531 9090</TEL>
<AGE>38</AGE>
</PERSON>
</PEOPLE>
Coming back to the simple example, say we would like to present out date in the following form table like form in HTML:
Name TelWe can create a stylesheet that specifies our desired layout:
Mark Wilson (619) 543 12345
Tracey Wilson (858) 531 9090
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<HTML>
<BODY>
<TABLE BORDER="2">
<TR>
<TD>Name</TD>
<TD>Tel</TD>
</TR>
<xsl:for-each select="PEOPLE/PERSON">
<TR>
<TD>
<xsl:value-of select="NAME" />
</TD>
<TD>
<xsl:value-of select="TEL" />
</TD>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
For more information about XSL please visit http://www.nwalsh.com/docs/tutorials/xsl/
from where I have taken some of this material.
The following example, taken from http://www.phpbuilder.com/columns/florian19991014.php3, shows an example of "How to store images directly in the SQL database ":
Create a database with a bin_data column that can hold BLOB:
CREATE TABLE binary_data (
id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY,
description CHAR(50),
bin_data LONGBLOB,
filename CHAR(50),
filesize CHAR(50),
filetype CHAR(50)
);
Read and store the binary data into the database:
Read binary data date from $bin_data which is either a file name or a URL
$data = addslashes(fread(fopen($bin_data, "r"), filesize($bin_data)))$result=MYSQL_QUERY("INSERT INTO binary_data (description,bin_data,filename,filesize,filetype) ".
"VALUES ('$bin_description','$data','$bin_data_name','$bin_data_size','$bin_data_type')");
Retrieve a BLOB from the database:
$query = "select bin_data,filetype from binary_data where id=$id";
$result = @MYSQL_QUERY($query);$data = @MYSQL_RESULT($result,0,"bin_data");
mail() automatically mails the message specified in message to the receiver specified in to. Multiple recipients can be specified by putting a comma between each address in to. Email with attachments and special types of content can be sent using this function. mail() returns TRUE if the mail is successfully sent, FALSE otherwise.
Example: mail("someone@aol.com", "Sample subject", "Sample message");
You can find more complex examples about mail on www.php.net,
including sending HTML messages and attachments, but for this project you
should use plain ASCII.
In Project 4 after the sender's message is validated the client needs to send an email notification to the receiver with the message included in ASCII. This email message should also include a URL the receiver should visit to get a nicer layout of the message. This can be done in the following way:
<?phpThe following is the output of this php script:function PostToHost($host, $path, $data_to_send) {
$fp = fsockopen($host,80);
printf("Open!\n");
fputs($fp, "POST $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: ".strlen($data_to_send)."\n");
fputs($fp, "Connection: close\n\n");
fputs($fp, "$data_to_send\n");
printf("Sent!\n");
while(!feof($fp)) {
$res .= fgets($fp, 128);
}
printf("Done!\n");
fclose($fp);return $res;
}$data = "Firm=&Urbanization=&Delivery+Address=10968+Canyon+Hill+Lane&City=San+Diego&State=CA&Zip+Code=&Submit=Process";
printf("Go!\n");
$x = PostToHost(
"www.usps.gov",
"/cgi-bin/zip4/zip4inq2",
$data
);
print "\n\n$x\n\n";
?>
Go! Open! Sent! Done! HTTP/1.1 200 OK Server: Netscape-Enterprise/4.0 Date: Fri, 16 Nov 2001 19:43:45 GMT Content-type: text/html Connection: close ZIP+4 Code LookupLook up another ZIP+4 Code | Questions and Comments
--------------------------------------------------------------------------------
The standardized address is:
10968 CANYON HILL LN
SAN DIEGO CA 92126-2054 Carrier Route : C043 County : SAN DIEGO
Delivery Point : 68 Check Digit : 5
--------------------------------------------------------------------------------
For other business lookup services: YellowPages.com
Version 5.0 Database 11/2001
Copyright © 1997 United States Postal Service. All rights reserved.
Developed by the USPS National Customer Support Center