I wish to pull some data from MySQL and insert it into numbered table rows. For the life of me I can't get it to work.
This is what I am trying to explain:
1 data from 1st record
data from 1st record
data from 1st record
data from 1st record
data from 1st record
2 data from 2nd record
data from 2nd record
data from 2nd record
data from 2nd record
data from 2nd record
and so on.
Here is my code snippet:
[code=php]$result = @mysql_query("SELECT DISTINCT SupplierName, MIBPostalAddress, MIBStreetAddress, LocationLocalBranch, LocalBranchPostCode, MIBTelephone, MIBFax FROM miris_Suppliers
WHERE MICCMember = 'yes'
ORDER BY miris_Suppliers.SupplierName");
if (!$result) {
echo ( "<h4>Error performing query: " . mysql_error() . "</h4>");
exit();
}
if ($row = mysql_fetch_array($result) )
{
do
{ // Declare each variable
$suppliername = $row["SupplierName"];
$mibpostaladdress = $row["MIBPostalAddress"];
$mibstreetaddress = $row["MIBStreetAddress"];
$locationlocalbranch = $row["LocationLocalBranch"];
$localbranchpostcode = $row["LocalBranchPostCode"];
$mibtelephone = $row["MIBTelephone"];
$mibfax = $row["MIBFax"];
printf("<table width=580 align=center cellspacing=0 cellpadding=0 border=0>");
printf("<tr><td rowspan=5 valign=top><br />[B](number goes here)[/B]</td><td><b>%s</b></td></tr>", htmlspecialchars($row["SupplierName"]));
if (strlen($mibpostaladdress) >0) {printf(" <tr><td>%s, %s. %s</td></tr>", htmlspecialchars($row["MIBPostalAddress"]), htmlspecialchars($row["LocationLocalBranch"]), $row["LocalBranchPostCode"]);}
if (strlen($mibstreetaddress) >0) {printf(" <tr><td>%s, %s. %s</td></tr>", htmlspecialchars($row["MIBStreetAddress"]), htmlspecialchars($row["LocationLocalBranch"]), $row["LocalBranchPostCode"]);}
if (strlen($mibtelephone) >0) {printf(" <tr><td>Telephone: %s</td></tr>", htmlspecialchars($row["MIBTelephone"]));}
if (strlen($mibfax) >0) {printf(" <tr><td>Fax: %s</td></tr>", htmlspecialchars($row["MIBFax"]));}
printf("</table>");
}
[/code]
Could kind coder help me out here?
Thanks
blueroo