home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Practical Internet Web Designer 90
/
PIWD90.iso
/
mac
/
contents
/
developer
/
tutorial_files
/
Pages88-89
/
articles.php
next >
Wrap
PHP Script
|
2003-10-29
|
2KB
|
55 lines
<?php
$thisCat = $_GET['catID'];
//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
$content = mysql_query("SELECT contentID, contentTitle,contentText FROM tblContent WHERE catID = " . $thisCat, $conn);
//query the database for a list of categories - for the navigation menu
$result = mysql_query("SELECT catID, catName, catDesc FROM tblCat", $conn);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Articles</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">
<?php
while ($contentrow = mysql_fetch_array($content)) {
$arrayDesc = explode(" ", $contentrow[contentText]);
$shortDesc = "";
for($i=0 ; $i<30 ; $i++) {
$shortDesc = $shortDesc . " " . $arrayDesc[$i];
}
print("<p><a href=\"showarticle.php?aID=" . $contentrow[contentID] . "\">" . $contentrow[contentTitle] . "</a><br />\n");
print($shortDesc . "</p>\n");
}
//you should close the connection when you are finished with it
mysql_close($conn);
?>
</div>
</body>
</html>