...

Display Data in Two Columns

Candrias77
09-25-2002, 07:53 AM
I am fairly new to php and mySQL so forgive me if this is a basic question.

I have a page of data that is coming out of the database formatted into table cells running down the page. I am wanting to display this in two columns, say if there were 11 entries, have 6 going down on the left and then 5 going down the right.

I presume i need to count them in some way and when more than half of them have been displayed enter some code to end the column and start the next one, then display the rest.

Any idea how to do this?

The code i am currently using is here:




<?
require("../local.inc.php");
?>

<html>
<head>

<?
$sql = "SELECT * FROM applicators WHERE region = '$region' ORDER BY company_name ";
$result = mysql_query($sql, $db) or user_error('Dang');
if (mysql_num_rows($result) > 0) {
?>

</head>
<body bgcolor="#ffffff" text="#000000">

<br>

<table width="100%" border="0" cellspacing="0" cellpadding="10">
<tr>
<td><b><font color="#B64000" size="3">
<? echo ($region) ?>
</font></b></td>
<td align="right"><a href="applicators_region1.htm">Back to city list</a></td>
</tr>
<tr>
<td colspan="2">
<table border="0" width="100%" cellspacing="1" cellpadding="3">
<?
while ($row = mysql_fetch_assoc($result)) {
?>
<tr>
<td> <b>
<? echo $row['company_name'] ?>
</b><br>
<? if ($row['applicator_name']) { ?>
<i>
<? echo $row['applicator_name'] ?>
</i><br>
<? } ?>
<? if ($row['address']) { ?>
<? echo $row['address'] ?>
<br>
<? } ?>
<? if ($row['phone']) { ?>
Ph:
<? echo $row['phone'] ?>
<br>
<? } ?>
<? if ($row['fax']) { ?>
Fax:
<? echo $row['fax'] ?>
<br>
<? } ?>
<? if ($row['mobile']) { ?>
Mobile:
<? echo $row['mobile'] ?>
<br>
<? } ?>
<? if ($row['email']) { ?>
<a href="mailto:<? echo $row['email'] ?>">Email</a><br>
<? } ?>
<? if ($row['website']) { ?>
<a href="http://<? echo $row['website'] ?>" target="_blank">Website</a>
<? } ?>
</td>
</tr>
<?
}
}
else
{
?>
<tr>
<td colspan="8">No applicators found.</td>
</tr>
</table>
<?
}
?>
</td>
</tr>
</table>

</body></html>




Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum