$row[0]
\n"; if ($row[0] == $category) // If current category matches the category in the list { // echo "Display all of the jokes in this category"; //echo ""; $query2="SELECT category, filename, title FROM jokes WHERE category = '$category' order by title asc"; $result2=mysql_query($query2); if(@mysql_num_rows($result2)) { $menu = $menu . ""; while($row = @mysql_fetch_row($result2)) { $row[1] = substr($row[1], 0, -4); $menu = $menu . "$row[2]
\n"; $title = $row[2]; } $menu = $menu . "
"; } //echo "
"; } } } $query="SELECT content FROM jokes WHERE filename = '$filename' AND category = '$category'"; $result=mysql_query($query); $contents=mysql_result($result,0,0); MYSQL_CLOSE(); $contents = nl2br($contents); //INSERT FOOTER //include('footer.php'); $smarty->assign('menu', $menu); $smarty->assign('title', $joketitle); $smarty->assign('contents', $contents); $smarty->display('template.tpl'); exit; } if($category) { $category = mysql_real_escape_string($category); $cattitle = $category; $smarty = new Smarty; $menu = ""; $query="SELECT DISTINCT category FROM jokes order by category asc"; $result=mysql_query($query); //Get the category list if(@mysql_num_rows($result)) { while($row = @mysql_fetch_row($result)) { $menu = $menu . "$row[0]
\n"; if ($row[0] == $category) // If current category matches the category in the list { // echo "Display all of the jokes in this category"; //echo ""; $query2="SELECT category, filename, title FROM jokes WHERE category = '$category' order by title asc"; $result2=mysql_query($query2); if(@mysql_num_rows($result2)) { $menu = $menu . ""; while($row = @mysql_fetch_row($result2)) { $row[1] = substr($row[1], 0, -4); $menu = $menu . "$row[2]
\n"; } $menu = $menu . "
"; } //echo "
"; } } } $smarty->assign('menu', $menu); $smarty->assign('title', $category); $smarty->assign('contents', "Please choose a joke to your left, you may need to scroll down to see the jokes in the category you chose."); MYSQL_CLOSE(); //INSERT FOOTER //include('footer.php'); $smarty->display('template.tpl'); exit; } MYSQL_CONNECT($dbserver,$dbuser,$dbpass) OR DIE("Unable to connect to database"); @mysql_select_db($dbname) or die("Unable to select database"); $smarty = new Smarty; // Make Menu $menu = ""; $query="SELECT DISTINCT category FROM jokes order by category asc"; $result=mysql_query($query); if(@mysql_num_rows($result)) { while($row = @mysql_fetch_row($result)) { $menu = $menu . "$row[0]
\n"; } } $smarty->assign('title', "Welcome to The Joke Site."); $smarty->assign('contents', "Please choose a joke category to your left."); $smarty->assign('menu', $menu); MYSQL_CLOSE(); if ($smarty) { $smarty->display('template.tpl'); } ?>