uservieworder.php
<?php
include("connect.php");
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover {
background-color: #111;
}
</style>
</head>
<body>
<body bgcolor="#919191">
<?php
if(isset($_SESSION['ID'])) //Checking if they have the session cookie
{
$result = mysql_query("SELECT * FROM orders INNER JOIN register WHERE customer_id ='".$_SESSION["ID"]."' LIMIT 10");
echo "<table border='1'>
<tr>
<th>User ID</th>
<th>Username</th>
<th>Prices</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['customer_id'] . "</td>";
echo "<td>" . $row['Username'] . "</td>";
echo "<td>" . $row['total_price'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
}
else
{
echo "<title>Error!</title>";
//Doesn't have session cookie
echo "YOU ARE NOT LOGGED IN!";
}
?>
</body>
</html>
connect.php
<?php
$hostname="localhost"; //local server name default localhost
$username="root"; //mysql username default is root.
$password=""; //blank if no password is set for mysql.
$database="register"; //database name which you created
$con=mysql_connect($hostname,$username,$password);
if(! $con)
{
die('Connection Failed'.mysql_error());
}
mysql_select_db($database,$con);
?>
with the code above , it show every data on the database.
echo "<td>" . $row['customer_id'] . "</td>";
echo "<td>" . $row['Username'] . "</td>";
echo "<td>" . $row['total_price'] . "</td>";
on the code above , ( customer_id, total_price data are from orders table, and Username are from register table )
I wanted that only show specific data based on session id only .