Hi Guyz,
I have hit a snag with the code I have been working on.
I am required to fetch database records from 3 tables and display them in both rows and columns.
For example, the output of the records on the web page is required to be as follows;
******************************************************************
*SCHOOL ADDRESS* SCHOOL NO: * EXTRA INFO *
*************** ************* ************ ************ **********
*2013:02:01 * 001 * School 1 * District 1 * Micheal *
*2013:02:02 * 001 * School 2 * District 2 * Ronald *
****************************************** ************ **********
So, the Invoice date is being gotten from one table called 'invoices' while Products is being gotten from a table called 'products'. These two are being linked using a common product_id.
I have tried out the following code, but it does not bring the results that I want. Here's the code I am working with;
<?php
error_reporting(0);
include('connect.php');
$query="select * from school_info, school WHERE school_info.school_id=school.school_id";
$result=mysql_query($query) or die(mysql_error());
$cols=5; // Here we define the number of columns
echo "<table>"; // The container table with $cols columns
do
{
echo "<tr>";
for($i=1;$i<=$cols;$i++)
{
$row=mysql_fetch_array($result);
if($row)
{
?>
<td>
<table>
<tr valign="top">
<td> </td> <!-- columns can have both text and images -->
<td>
<b><?php echo $row['school_name']; ?></b><br />
<?php echo $row['district']; ?><br />
<?php echo $row['person_in_charge']; ?><br />
</td>
<td width="50"> </td> <!-- Create gap between columns -->
</tr>
</table>
</td>
<?php
}
else
{
echo "<td> </td>"; //If there are no more records at the end, add a blank column
}
}
}
while($row);
echo "</table>";
?>
Thank you in advance