ibrahiemrafiq
New member
I am trying to get data out of two tables to reference one another. for example in my orders table there is an Event_ID and in my events table there is an Event_ID. Currently my output for orders shows the Event_ID stored in the DB, but I want it to display the Event_Title instead. I am sure it invloves a complex query but i can't get it. i have posted the code below:
<?php
session_start();
if (isset($_SESSION["authenticatedUser"]))
{
$_SESSION["message"] = "You are already logged in as ". $_SESSION['authenticatedUser'];
}
?>
<?php
require_once('inc/mysql.class.php');
require_once('inc/global.inc.php');
require_once('inc/functions.inc.php');
require_once('connection.php');
?>
<?php
$query111 = "select Customer_ID from Proj_Customer_Details where email = '$_SESSION[authenticatedUser]'";
//echo "$query111";
$result111 = mysql_query ($query111) or die (mysql_error());
if (mysql_num_rows($result111)>0)
{
while($row111=mysql_fetch_array($result111))
{
$customer_idt = $row111['Customer_ID'];
}
}
$query1121 = "select * from Proj_Order where Customer_ID = '$customer_idt'";
$result1121 = mysql_query ($query1121) or die (mysql_error());
while ($row22 = @ mysql_fetch_array($result1121)) {
echo "<table>";
echo"<tr><td>OrderID</td><td>EventID</td><td>CustomerID</td><td>QTY</td><td>TotalPrice</td><td>Date</td></tr>";
echo "<tr>";
echo "<td>".$row22["Order_ID"]."</td>";
echo "<td>".$row22["Event_ID"]."</td>";
echo "<td>".$row22["Customer_ID"]."</td>";
echo "<td>".$row22["qty"]."</td>";
echo "<td>£".$row22["Order_TotalPrice"]."</td>";
echo "<td>".$row22["Order_Date"]."</td>";
echo "</tr>";
}
echo "<tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
echo "</table>";
?>
<?php
session_start();
if (isset($_SESSION["authenticatedUser"]))
{
$_SESSION["message"] = "You are already logged in as ". $_SESSION['authenticatedUser'];
}
?>
<?php
require_once('inc/mysql.class.php');
require_once('inc/global.inc.php');
require_once('inc/functions.inc.php');
require_once('connection.php');
?>
<?php
$query111 = "select Customer_ID from Proj_Customer_Details where email = '$_SESSION[authenticatedUser]'";
//echo "$query111";
$result111 = mysql_query ($query111) or die (mysql_error());
if (mysql_num_rows($result111)>0)
{
while($row111=mysql_fetch_array($result111))
{
$customer_idt = $row111['Customer_ID'];
}
}
$query1121 = "select * from Proj_Order where Customer_ID = '$customer_idt'";
$result1121 = mysql_query ($query1121) or die (mysql_error());
while ($row22 = @ mysql_fetch_array($result1121)) {
echo "<table>";
echo"<tr><td>OrderID</td><td>EventID</td><td>CustomerID</td><td>QTY</td><td>TotalPrice</td><td>Date</td></tr>";
echo "<tr>";
echo "<td>".$row22["Order_ID"]."</td>";
echo "<td>".$row22["Event_ID"]."</td>";
echo "<td>".$row22["Customer_ID"]."</td>";
echo "<td>".$row22["qty"]."</td>";
echo "<td>£".$row22["Order_TotalPrice"]."</td>";
echo "<td>".$row22["Order_Date"]."</td>";
echo "</tr>";
}
echo "<tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
echo "</table>";
?>