Hi all,
I am using PHP and SQL to display results of database query.
On the html page, each row of data sholuld be displayed on html table rows.
One Database Table(tableA) contains many rows all related to one ID from another Database table(table๐.
My problem is trying to get all the results from tableA to display in one table row on the webpage.
At the moment, the multiple table results from tableA causes tableB data to be displayed repeatedly.
How do I solve this? Thanks and Happy Christmas.
// perform query
$query = "SELECT * ".
"FROM tableB B ".
"LEFT JOIN tableA A ".
"ON B.ID = A.ID";
$result = mssql_query($query) or die('Select Error');
$num_results = mssql_num_rows($result);
if ($num_results > 0)
{
echo '<table> '.
'<tr><th>SECURITY ID</th><th>EX DATE</th> '.
'<th>SUBMIT QUERY</th></tr>';
while ($row = mssql_fetch_array($result))
{
echo '<tr>'.
'<td>'.$row['security_ID'].'</td> '.
'<td>'.$row['ex_date'].'</td> '.
'<td><a href="submit_query/index.php?id='.$row['corporate_ID'].'" > '.
'<img src="../images/email.gif" title="Submit Query" /> '.
'</a></td> '.
'</tr>';
}
echo '</table>';
} // end if