home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 88 / PIWD88.iso / mac / contents / developer / tutorial_files / Pages88-89 / showarticle.php < prev    next >
PHP Script  |  2003-10-29  |  1KB  |  99 lines

  1. <?php
  2.  
  3. $thisArticle = $_GET['aID'];
  4.  
  5. //connect to the database
  6.  
  7. $conn = mysql_connect("localhost","root","pwd");
  8.  
  9. //choose the cms db
  10.  
  11. mysql_select_db("cms", $conn);
  12.  
  13. //query the database for a list of the content for this category
  14.  
  15. $article = mysql_query("SELECT contentTitle,contentText FROM tblContent WHERE contentID = " . $thisArticle, $conn);
  16.  
  17. //query the database for a list of categories - for the navigation menu
  18.  
  19. $result = mysql_query("SELECT catID, catName, catDesc FROM tblCat", $conn);
  20.  
  21.  
  22.  
  23. //get the article title and content into variables
  24.  
  25. while ($articlerow = mysql_fetch_array($article)) {
  26.  
  27.     $title = $articlerow['contentTitle'];
  28.  
  29.     $content = $articlerow['contentText'];
  30.  
  31.     
  32.  
  33. }
  34.  
  35. //you should close the connection when you are finished with it
  36.  
  37. mysql_close($conn);
  38.  
  39. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  40.  
  41.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  42.  
  43.  
  44.  
  45. <html>
  46.  
  47. <head>
  48.  
  49. <title><?print $title?></title>
  50.  
  51. <link rel="stylesheet" type="text/css" href="global.css" />
  52.  
  53. </head>
  54.  
  55.  
  56.  
  57. <body>
  58.  
  59. <div id="banner">
  60.  
  61. <p> </p>
  62.  
  63. </div>
  64.  
  65. <div id="navigation">
  66.  
  67. <ul class="main">
  68.  
  69. <?php
  70.  
  71. //the navigation menu
  72.  
  73. while ($row = mysql_fetch_array($result)) {
  74.  
  75.     print("<li><a href=\"articles.php?catID=" . $row[catID] . "\">" . $row[catName] . "</a></li>\n");
  76.  
  77. }
  78.  
  79. ?>
  80.  
  81. </ul>
  82.  
  83. </div>
  84.  
  85. <div id="content">
  86.  
  87. <h1><?print $title?></h1>
  88.  
  89. <p><?print $content?></p>
  90.  
  91. </div>
  92.  
  93. </body>
  94.  
  95. </html>
  96.  
  97.  
  98.  
  99.