Source for file muffinview.php

Documentation is available at muffinview.php

  1. <?
  2. /**
  3.  * muffinview.php shows details of a single muffin, as set up by muffinlist.php
  4.  * 
  5.  * This page requires a loaded querystring, with an id number of a muffin passed to it.
  6.  *
  7.  * If no valid id number is passed, the user is forcibly redirected to muffinlist.php
  8.  *
  9.  * @package ITC280
  10.  * @author Bill Newman <williamnewman@gmail.com>
  11.  * @version 1.0 2008/05/03
  12.  * @link http://www.newmanix.com/itc280/
  13.  * @license http://opensource.org/licenses/osl-3.0.php Open Software License ("OSL") v. 3.0
  14.  * @see muffinlist.php
  15.  * @todo none
  16.  */
  17.  
  18. /**
  19.  * If TRUE, will show errors on page, instead of making errors private.
  20.  * This variable can be over-ridden by $HideAllErrors variable in configINC.php
  21.  * @global boolean $HidePageErrors 
  22.  */
  23. $HidePageErrors FALSE
  24.  
  25. //END CONFIG AREA ---------------------------------------------------------- 
  26.  
  27. /**
  28.  * Provides 'myerror()' for error handling, and conn() for db connection
  29.  */
  30. include_once("include/utilINC.php");
  31.  
  32. //check variable of item passed in on querystring
  33. if(isset($_GET['id'])){
  34.         $myID (stripslashes(trim($_GET['id'])));
  35.          if(!is_numeric($myID)){myRedirect("muffinlist.php");}//no number, redirect
  36. }else{
  37.         myRedirect("muffinlist.php")//nothing on querystring, redirect
  38. }
  39.  
  40. /**
  41.  * SQL statement - to select individual muffin via id passed on querystring
  42.  * @var string 
  43.  */
  44. $selSQL "select MuffinName, Description, Price from bnewman.tblMuffins where MuffinID = " $myID;
  45.  
  46. $myConn conn();//create connection to MySQL
  47. ob_start()//required for myRedirect() must precede any HTML
  48. ?>
  49. <html>
  50. <body>
  51. <h2 align=center>Show Me the Muffin! (muffinview.php)</h2>
  52. <?
  53. $result @mysql_query($selSQL,$myConnor die(myerror(__FILE__,__LINE__,mysql_error()));
  54. $numRows mysql_num_rows($result);
  55. if ($numRows 0)//at least one record!
  56. {//show results
  57.    while ($row mysql_fetch_array($result))
  58.    {
  59.          $MuffinName dbOut($row['MuffinName']);
  60.          $Description dbOut($row['Description']);
  61.          $Price dbOut($row['Price']);
  62.     }
  63. }else{//no records
  64.     print '<div align="center">There is no such muffin! <a href="muffinlist.php">ANOTHER MUFFIN?</a></div>';
  65.     print "</body></html>";
  66.     die();
  67. }
  68. ?>
  69. <h1 align="center"><font color="red"><?=$MuffinName;?></font></h1></div>
  70. <div align="center"><a href="muffinlist.php">More Muffins!</a></div>
  71. <table align="center">
  72.     <tr>
  73.         <td><img src="images/m<?=$myID?>.jpg" /></td>
  74.         <td><h2><b>Muffin: <font color="blue"><?=$MuffinName;?></font><b></h2></td>
  75.     </tr>
  76.     <tr>
  77.         <td colspan="2">
  78.             <blockquote><?=$Description?></blockquote>
  79.         </td>
  80.     </tr>
  81.     <tr>
  82.         <td align="center" colspan="2">
  83.             <h3><i>ONLY!!:</i> <font color="red">$<?=money_format('%(#10n',$Price)?></font></h3>
  84.         </td>
  85.     </tr>
  86. </table>
  87. </body>
  88. </html>
  89. <?
  90. @mysql_close()//close connection to db
  91. ob_flush()//prevents header errors
  92. ?>

Documentation generated on Sat, 03 May 2008 19:47:45 -0700 by phpDocumentor 1.4.1