I have a mySQL table named businesses with 4 columns.
name, url, description, category
I am trying to have the entire directory display on a page under each corresponding category name. Is there a better way to do this than what I have so far? I would like to keep all data in one table rather than having a table for each category.
<?php
$con = mysql_connect('localhost','username','password')
or die('Could not connect: ' . mysql_error());
mysql_select_db('relicc_dogedir')
or die('Could not select database');
$result = mysql_query("SELECT * FROM businesses ORDER BY category",$con);
$column = array();
while($row = mysql_fetch_array($result))
{
$column[] = $row['category'];
}
$merged_column = array_unique($column);
$refined_categories = array_values($merged_column);
foreach ($refined_categories as &$refined_category)
{ ?>
<h3><?php echo $refined_category;?></h3><?php
//Display sorted business names with corresponding category
}
mysql_close($con);
?>