home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Practical Internet Web Designer 90
/
PIWD90.iso
/
mac
/
contents
/
developer
/
tutorial_files
/
Pages88-89
/
showarticle.php
< prev
next >
Wrap
PHP Script
|
2003-11-23
|
1KB
|
50 lines
<?php
$thisArticle = $_GET['aID'];
//connect to the database
$conn = mysql_connect("localhost","root","pwd");
//choose the cms db
mysql_select_db("cms", $conn);
//query the database for a list of the content for this category
$article = mysql_query("SELECT contentTitle,contentText FROM tblContent WHERE contentID = " . $thisArticle, $conn);
//query the database for a list of categories - for the navigation menu
$result = mysql_query("SELECT catID, catName, catDesc FROM tblCat", $conn);
//get the article title and content into variables
while ($articlerow = mysql_fetch_array($article)) {
$title = $articlerow['contentTitle'];
$content = $articlerow['contentText'];
}
//you should close the connection when you are finished with it
mysql_close($conn);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title><?print $title?></title>
<link rel="stylesheet" type="text/css" href="global.css" />
</head>
<body>
<div id="banner">
<p> </p>
</div>
<div id="navigation">
<ul class="main">
<?php
//the navigation menu
while ($row = mysql_fetch_array($result)) {
print("<li><a href=\"articles.php?catID=" . $row[catID] . "\">" . $row[catName] . "</a></li>\n");
}
?>
</ul>
</div>
<div id="content">
<h1><?print $title?></h1>
<p><?print nl2br($content)?></p>
</div>
</body>
</html>