简体   繁体   中英

How to make check history based on user logged in

i want to make order history but only the order that has been ordered by the current user that has 'logged in'.. anybody can help me?

<?php
include("includes/db.php");
include("authentication.php");

session_start();
$id=$_GET["id"];
$query="SELECT * FROM order_detail";
$result=mysql_query($query);

if($_SESSION["sessionusername"])
{
echo" <html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
<title>Untitled Document</title>
</head>
<body>
<table align='center' width='40%'>
<tr><td width='10%'><img src='image/banner.jpg' width='1000' height='150' alt='Master'><td></tr>                   
</table>
<table align='center' width='70%'>
<tr>
<td width='10%' align='center'><a href ='home.php'>Home</a></td><td width='15%'        align='center'><a href='aboutus.php'>About Us</a></td>
<td width='14%' align='center'><a href='news.php'>News</a></td><td width='13%'   align='center'><a href='products.php'>Products</a></td>
<td width='14%' align='center'></td>
<td width='13%' align='center'><a href='checkhistory.php'>Order History</a></td>
</tr>
</table>"; }
else
{ 
echo "<center>You Must Login First !</center>"; 
}
  ?>


<?php


while($data=mysql_fetch_array($result))
{
 $orderid=$data["orderid"];
$productid=$data["productid"];
$quantity=$data["quantity"];
$price=$data["price"];
$serial=$data["serial"];
$name=$data["name"];
$description=$data["description"];
?>
<table><tr><td>Order id : <?php echo $orderid ?></td>
<td>Order id : <?php echo $productid ?></td> <td>Order id : <?php echo $quantity?></td>
<td>Order id : <?php echo $price ?></td> <td>Order id : <?php echo $Serial ?></td>
<?php }?>
</tr></table>

i want to make order history. which if i click order history automatically it will show the order details that have been order by the current user that has 'logged'in'

im really confused on what to do.. please helpppp !!

Thanks a lot

您必须在SQL查询中添加WHERE user_field = :currentUserName ,其中user_field是订单表中的用户标识符,而:currentUserName是当前用户

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM