create a table of certain num of columns

wxdqz

New Member
I have a database of dealer info - name, address1, address2, city, state, zip, phone, fax, email, all seperate fields of course. I want to build a web page table with 3 columns and as many rows as necessary to display all dealers for a particular state. Here is what I have and it's not working -
----------------
<?
$db = mysql_connect("localhost", "root") or die ("Problem connecting to Database");
mysql_select_db("dealers", $db) or die ("Can't get the database");
if ($orderby == 'AL'):
$query = "select * from dealers where State = 'AL' order by 'DealerName'";
elseif ($orderby == 'GA'):
$query = "select * from dealers where State = 'GA' order by 'DealerName'";
elseif ($orderby == 'MS'):
$query = "select * from dealers where State = 'MS' order by 'DealerName'";
else:
$query = "select DealerName from dealers";
endif;

$result = mysql_query($query);

while ( $row = mysql_fetch_array($result))
{
$count = 0;

{
if ($count == 0)
{
print("<tr>");
printf("<td>\n<font color=\"blue\">%s</font>\n", $row["DealerName"]);
printf("<br>%s\n", $row["Address1"]);
printf("<br>%s\n", $row["Address2"]);
printf("<br>%s, %s %s\n", $row["City"], $row["State"], $row["Zipcode"]);
printf("<br>Phone: %s\n", $row["Phone"]);
printf("<br>FAX: %s\n", $row["FAX"]);
printf("<br>\n<a href=http://www.phpbuilder.com/board/archive/index.php/\"mailto:%s\">%s</a>", $row["Email"], $row["Email"]);
print("<br>\n<hr width=\"50%\">\n</td>\n");
}
$count++;
if ($count == 3);
{
print("</TR>");
$count = 0;
}
}
}
?>
</table>
--------------------
(jeez, pasting that in here really messed up the formatting, hope it turns out okay in the post).
The loop is not working, I get one column only, otherwise it is returning the info for each state as chosen by the visitor.
 
Back
Top