Advertisement
giraffeinatutu

Orders

Aug 28th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.65 KB | None | 0 0
  1. <?php  
  2.         session_start();
  3.     if( !isset( $_SESSION['fname'] ))
  4.     {
  5.     header("location: CR_login.php");
  6.     }
  7. unset($_SESSION['counter']);
  8.  
  9.     // Establish a connection to the database
  10.     $con =  mysqli_connect("localhost", "cairil_php", "phpsql");
  11.  
  12.     // Check if there were any issues connecting to the database
  13.     if ( mysqli_connect_errno() != 0)
  14.     {
  15.        die("An error occurred trying to establish a connection: " .mysqli_connect_error());
  16.     }
  17.    
  18.     // Select the  database to work with.
  19.     $db  =  mysqli_select_db ($con , "cairil_php");
  20.  
  21.            
  22.     ?>
  23.    
  24. <html>
  25.     <head>
  26.         <title> CR_orders.php </title>
  27.     </head>
  28.  
  29. <center>
  30. <h1>Welcome <?php echo(($_SESSION['fname']) . " " . ($_SESSION['lname'])) ?></h1>
  31. <br />
  32. <h2>Order Detail</h3>
  33. <table border="2" align="center">
  34. <tbody>
  35. <tr bgcolor="#33A1C9"><th align="center">Order ID</th><th align="center">Customer ID</th><th align="center">Order Date</th><th>Details</th></tr>
  36. <?php
  37.                
  38.             // Specify the query to run
  39.             $orders = "SELECT ('OrderID','CustomerID','OrderDate') FROM `Orders` WHERE `cust_id` = '". $_SESSION['cid'] ."'";
  40.            
  41.             if ($result = mysqli_query($con, $orders))
  42.             {
  43.             $rowcount = mysqli_num_rows($result);
  44.            
  45.             if( $rowcount > 0) {
  46.            
  47.             while ($row = mysqli_fetch_array ($ors)) {
  48.                 echo("<tr><td>");
  49.                 echo($row["OrderID"]);
  50.                 echo("</td><td>");
  51.                 echo($row["CustomerID"]);
  52.                 echo("</td><td>");
  53.                 echo($row["OrderDate"]);
  54.                 echo("</td><td>");
  55.                 echo("See Detail");
  56.                 }          
  57.             // Destroy the result object and release its memory
  58.             mysqli_free_result($rs);
  59.                 }
  60.             }
  61.             else
  62.             {
  63.             echo (($_SESSION['fname']) . " " . ($_SESSION['lname']). " you have no orders. <br><br>");
  64.             }      
  65.            
  66.            
  67.                
  68.             // Close the connection
  69.             mysqli_close($con);    
  70.         ?></td></tr>
  71. <tr bgcolor="#33A1C9">
  72. <td colspan="4" align="center"></td>
  73. </tr>
  74. </tbody>
  75. </table>
  76.        
  77. <br />
  78. <h3>***********************************************************************************************</h3>
  79. <br />
  80. <table>
  81. <tr>
  82. <td><a href=CR_products.php><img title"view products" src="/images/b-products.png" alt="View Product" /></a>
  83.     <a href=CR_cart.php><img title"view cart" src="/images/b-shopping.png" alt="View Cart" /></a>
  84.     <a href=CR_change.php><img title"change pass" src="/images/b-change.png" alt="Change Password"/></a></td></tr>
  85.     <tr></tr>    <tr></tr>
  86.     <tr><td align="center"><a href=CR_welcome.php><img title="home" src="/images/home_button.png" alt="home" width="150" height="50"/></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=CR_logout.php><img title"logout" src="/images/exit_button.jpg" alt="Logout" /></a></td></tr>
  87. </table>    
  88. </center>
  89. </body>
  90. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement