Php 如何根据用户登录情况创建检查历史记录

Php 如何根据用户登录情况创建检查历史记录,php,Php,我想创建订单历史记录,但只创建已“登录”的当前用户订购的订单。。 有人能帮我吗 <?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"

我想创建订单历史记录,但只创建已“登录”的当前用户订购的订单。。 有人能帮我吗

<?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>

您必须在SQL查询中添加
其中user\u字段=:currentUserName
,其中
user\u字段
是订单表中的用户标识符,
:currentUserName
是您的当前用户