Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if( !isset( $_SESSION['fname'] ))
- {
- header("location: CR_login.php");
- }
- unset($_SESSION['counter']);
- // Establish a connection to the database
- $con = mysqli_connect("localhost", "cairil_php", "phpsql");
- // Check if there were any issues connecting to the database
- if ( mysqli_connect_errno() != 0)
- {
- die("An error occurred trying to establish a connection: " .mysqli_connect_error());
- }
- // Select the database to work with.
- $db = mysqli_select_db ($con , "cairil_php");
- ?>
- <html>
- <head>
- <title> CR_orders.php </title>
- </head>
- <center>
- <h1>Welcome <?php echo(($_SESSION['fname']) . " " . ($_SESSION['lname'])) ?></h1>
- <br />
- <h2>Order Detail</h3>
- <table border="2" align="center">
- <tbody>
- <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>
- <?php
- // Specify the query to run
- $orders = "SELECT ('OrderID','CustomerID','OrderDate') FROM `Orders` WHERE `cust_id` = '". $_SESSION['cid'] ."'";
- if ($result = mysqli_query($con, $orders))
- {
- $rowcount = mysqli_num_rows($result);
- if( $rowcount > 0) {
- while ($row = mysqli_fetch_array ($ors)) {
- echo("<tr><td>");
- echo($row["OrderID"]);
- echo("</td><td>");
- echo($row["CustomerID"]);
- echo("</td><td>");
- echo($row["OrderDate"]);
- echo("</td><td>");
- echo("See Detail");
- }
- // Destroy the result object and release its memory
- mysqli_free_result($rs);
- }
- }
- else
- {
- echo (($_SESSION['fname']) . " " . ($_SESSION['lname']). " you have no orders. <br><br>");
- }
- // Close the connection
- mysqli_close($con);
- ?></td></tr>
- <tr bgcolor="#33A1C9">
- <td colspan="4" align="center"></td>
- </tr>
- </tbody>
- </table>
- <br />
- <h3>***********************************************************************************************</h3>
- <br />
- <table>
- <tr>
- <td><a href=CR_products.php><img title"view products" src="/images/b-products.png" alt="View Product" /></a>
- <a href=CR_cart.php><img title"view cart" src="/images/b-shopping.png" alt="View Cart" /></a>
- <a href=CR_change.php><img title"change pass" src="/images/b-change.png" alt="Change Password"/></a></td></tr>
- <tr></tr> <tr></tr>
- <tr><td align="center"><a href=CR_welcome.php><img title="home" src="/images/home_button.png" alt="home" width="150" height="50"/></a> <a href=CR_logout.php><img title"logout" src="/images/exit_button.jpg" alt="Logout" /></a></td></tr>
- </table>
- </center>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement