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 >
PHP Script  |  2003-11-23  |  1KB  |  50 lines

  1. <?php
  2. $thisArticle = $_GET['aID'];
  3. //connect to the database
  4. $conn = mysql_connect("localhost","root","pwd");
  5. //choose the cms db
  6. mysql_select_db("cms", $conn);
  7. //query the database for a list of the content for this category
  8. $article = mysql_query("SELECT contentTitle,contentText FROM tblContent WHERE contentID = " . $thisArticle, $conn);
  9. //query the database for a list of categories - for the navigation menu
  10. $result = mysql_query("SELECT catID, catName, catDesc FROM tblCat", $conn);
  11.  
  12. //get the article title and content into variables
  13. while ($articlerow = mysql_fetch_array($article)) {
  14.     $title = $articlerow['contentTitle'];
  15.     $content = $articlerow['contentText'];
  16.     
  17. }
  18. //you should close the connection when you are finished with it
  19. mysql_close($conn);
  20. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  21.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  22.  
  23. <html>
  24. <head>
  25. <title><?print $title?></title>
  26. <link rel="stylesheet" type="text/css" href="global.css" />
  27. </head>
  28.  
  29. <body>
  30. <div id="banner">
  31. <p> </p>
  32. </div>
  33. <div id="navigation">
  34. <ul class="main">
  35. <?php
  36. //the navigation menu
  37. while ($row = mysql_fetch_array($result)) {
  38.     print("<li><a href=\"articles.php?catID=" . $row[catID] . "\">" . $row[catName] . "</a></li>\n");
  39. }
  40. ?>
  41. </ul>
  42. </div>
  43. <div id="content">
  44. <h1><?print $title?></h1>
  45. <p><?print nl2br($content)?></p>
  46. </div>
  47. </body>
  48. </html>
  49.  
  50.