Hey all,
I'm trying to display query results from three different tables using inner joins. The database connects okay, the headers are displayed but no data is being displayed.
The query works fine in PHPMyAdmin, and the PHP is taken from it, but still no results.
Code as follows:
<?php
$username = "MyUsername";
$password = "MyPassword";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
$selected = mysql_select_db("MyDBName",$dbh)
or die("Could not select DB");
$sql = 'SELECT tblClaims.SeqNum, tblClaims.Glass_Company, tblClaims.GlassCoId, tblClaims.Date_Faxed, tblInsuranceCompanies.Cmpny, tblInvoices.InvoiceTotal, tblClaims.GlassCoInvNum, tblClaims.GlassCoInvDate, tblClaims.Program, tblClaims.Glass_Company'
. ' FROM (tblClaims INNER JOIN tblInvoices ON tblClaims.SeqNum = tblInvoices.SeqNum) INNER JOIN tblInsuranceCompanies ON tblClaims.CustID = tblInsuranceCompanies.Abrvtn'
. ' WHERE (((tblClaims.Program)="tgn"));';
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
//Display the Information
echo "<table border='1'>";
echo "<tr> <th>Column1</th> <th>Column2</th> <th>Column3</th> <th>Column4</th> <th>Column5</th> <th>Column6</th> <th>Column7</th> <th>Column8</th> <th>Column9</th></tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array($result))
{
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['Column1'];
echo "</td><td>";
echo $row['Column2'];
echo "</td><td>";
echo $row['Column3'];
echo "</td><td>";
echo $row['Column4'];
echo "</td><td>";
echo $row['Column5'];
echo "</td><td>";
echo $row['Column6'];
echo "</td><td>";
echo $row['Column7'];
echo "</td><td>";
echo $row['Column8'];
echo "</td><td>";
echo $row['Column9'];
echo "</td></tr>";
echo "</table>";
}
mysql_close($dbh);
?>
Am I missing anything... or any suggestions?
Thx