[Sussex] PHP and XML
Mark Harrison
Mark at ascentium.co.uk
Tue Oct 21 16:32:50 UTC 2003
Matthew,
In case it helps, here's a PHP file that works (for me at least.) I tend to
write "native" XHTML into the body of the file, and only start executing PHP
for the dynamic bits...
You should note that this is from the development server - the live site is
going to have better written prose :-)
Regards,
Mark
--------------------------------------------------
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>StartInvesting.co.uk Resources</title>
<link type="text/css" rel="stylesheet" href="style.css">
</head>
<body>
<H2>StartInvesting.co.uk</H2>
<table align=center border="1" cellspacing="0" width="820" valign="top">
<tr height="10">
<td width="10" background="topleft.jpg"></td>
<td width="800" background="top.jpg" valign="top"></td>
<td width="10" background="topright.jpg"> </td>
</tr>
<tr>
<td width="10" background="left.jpg"></td>
<td width="800" bgcolor=white valign="top">Welcome to
StartInvesting.co.uk. If you are considering investing in the UK property
market, this site is for you. Of course it's going to make us rich as well,
but that's the price of freedom, kiddo.</td>
<td width="10" background="right.jpg"></td>
</tr>
<tr height="10">
<td width="10" background="bottomleft.jpg"></td>
<td width="800" background="bottom.jpg" valign="bottom"></td>
<td width="10" background="bottomright.jpg"> </td>
</tr>
</table>
<p/>
<table width="100%" align=center border=10>
<tr valign="top">
<td width="5%"> </td>
<td bgcolor=white width="15%"><p><A HREF="index.html">Home</A></p>
<p><B>resources</B></p>
<p>agents</p>
<p>buying</p>
<p>books</p>
<p>seminars</p>
<p>affiliates</p>
<p>software</p>
</td>
<td width="5%"> </td>
<td width="60%">
<?php
$connection=mysql_connect("localhost","root","");
$db=mysql_select_db("stories");
$sql="Select * from stories, authors where
stories.authorID=authors.authorID;";
$mysqlresult=mysql_query($sql,$connection);
$numberofrows=mysql_num_rows($mysqlresult);
if ($numberofrows==0) {
echo "sorry, no results returned";
}
else {
echo "<TABLE background=\"white.jpg\" width=\"100%\" BORDER=0>";
while ($row=mysql_fetch_array($mysqlresult))
{
$StoryID=$row["StoryID"];
$Title=$row["Title"];
$Author=$row["AuthorName"];
$Summary=$row["Summary"];
$Content=$row["Content"];
echo "<TR><TD><B>$Title</B></TD><TD><font
size=-1>$Author</font></TD></TR><TR><TD><A
HREF=\"story.php?index=$StoryID\">$Summary<A><hr/></TD></TR>";
} #end while
echo "</table>";
} #end else
?>
</td>
<td width="5%"> </td>
<td bgcolor=gray width="15%">And now, a word from our sponsors<p><b>Buy
Our Stuff, Dammit</b></td>
<td width="5%"> </td>
</tr>
</table>
</body>
</html>
More information about the Sussex
mailing list