I've got an application that prints the results of of a mall directory. Within this directory it calls 2 different tables from a db and prints accordingly.
Now my dilemma is i have a limited amount of physical space to display these stores and html version of the final output can be found below :
http://universitymallnc.com/index.php?pageType=directory
As far as printing these items out dynamically this is the final output i have so far
http://universitymallnc.com/testbed/index.php?pageType=directory
As you can tell the categories are not matching so that the items will be displayed without pushing the footer passed its mark.
Below is the code I have so far :
function display_stores($catid) {
$storeDB = mysql_connect("localhost","user","pass");
mysql_select_db("malldb",$storeDB);
//$storesResult = mysql_query("SELECT * FROM directory WHERE store_cat='" . $category . "'",$storeDB);
$storesResult = mysql_query("SELECT * FROM directory WHERE store_cat='" .$catid. "'",$storeDB);
$storesTotRows = mysql_num_rows($storesResult);
for ($i=0;$i<$storesTotRows;$i++) {
$store_row=mysql_fetch_array($storesResult);
echo $store_row['store_name'] . "<br />";
}
echo "<br />";
}
function query_category() {
$catDB = mysql_connect("localhost","user","pass");
mysql_select_db("malldb",$catDB);
$catResult = mysql_query("SELECT * FROM dir_category",$catDB);
$catTotRows = mysql_num_rows($catResult);
// Split columns here
$half=(intval($catTotRows)/3);
$new_col=0;
echo "<table><tr><td>";
for ($i=0;$i<$catTotRows;$i++) {
$cat_row=mysql_fetch_array($catResult);
echo "<strong>" . $cat_row['cat_name'] . "</strong><br />";
display_stores($cat_row['cat_id']);
$new_col=$new_col+1;
if ($new_col>$half) {
echo"</td><td>";
$new_col=0;
}
}
echo "</tr></table>";
}
Any advice as to how to maybe push the results to fill up the first column before continueing to the next? Keep in mind this code is basically querying the total categories i have in my database and basing the columns off of that rather than the store results which i know would work better but it only bases the results off the query of the catid 🙁
any help is appreciated
note: im thinking the use of perhaps sql table joins to pull this off, however, im still limited as to what i can do with table joins