I have 3 tables that I need to join: Orders, CartProducts, OtherServices. The Orders table is the one that holds the items they want to purchase but a numeric value is store on the tables so I need to join the other two tables to get the actual name of the Product and Service. The problem is that not all the time there will be a numeric value on the "Orders" table.
Here is the code that I have.
<?php
$colname_rsOrder = "-1";
if (isset($GET['ord'])) {
$colname_rsOrder = $GET['ord'];
}
$colCustomerID_rsOrder = "-1";
if (isset($GET['urid'])) {
$colCustomerID_rsOrder = $GET['urid'];
}
mysql_select_db($database_MyShoe, $MyShoe);
$query_rsOrder = sprintf("SELECT * FROM CartProducts INNER JOIN Orders LEFT JOIN OtherServices LEFT JOIN Lift ON Orders.OrderNumber = %s AND Orders.OrderCustomerID = %s ON Orders.ProductService = CartProducts.ProID ORDER BY OrderID ASC", GetSQLValueString($colname_rsOrder, "text"),GetSQLValueString($colCustomerID_rsOrder, "text"));
$rsOrder = mysql_query($query_rsOrder, $MyShoe) or die(mysql_error());
$row_rsOrder = mysql_fetch_assoc($rsOrder);
$totalRows_rsOrder = mysql_num_rows($rsOrder);
?>