Forum Moderators: coopster
No matter what I do the column on the right side (populated with categories from the database) is shorter than the column on the left side. Currently the output result from the database is producing 69 category links in the left column and 37 category links on the right column. Everything else is fine.
Any ideas on how to adjust this? Thanks Rick
=====================================================
// retreive the results
// set by you - how many columns of results do you wish?
$columnsWanted = 2;
$estimatedScreenWidth = 620; // pixels wide
$totalRows = $totalCategories; // is determined above by the database query
$avgColumnWidth = round($estimatedScreenWidth / $columnsWanted);
$rowsPerColumn = round($totalRows / $columnsWanted ); // returns the nearest integer value
$displayedCategories = 0;
echo"\n\n\n<table><tr>\n";
$columnCount = 0;
while( $columnCount < $columnsWanted ) {
echo"<td width=\"$avgColumnWidth\" align=\"left\" valign=\"top\">\n";
for( $rowsThisCell=0; $rowsThisCell < $rowsPerColumn; $rowsThisCell++ ) {
//echo $rowsThisCell . "<br>\n";
if($grabARecord = mysql_fetch_array ($queryResultHandle)){
++$displayedCategories;
$category = stripslashes($grabARecord["category"]);
$listingsInACategory = $grabARecord["LISTINGCOUNT"];
// convert the possibly space filled text into a continuous string
$encodedCategory = urlencode($category);
// generate the hyperlink and the correct search type
echo "<a href=\"" . INSTALLPATH . "result.php?goal=$blahblahblah\">$category" . "</a><br>";
}
} // for
// if there is an "odd" number category still not included in the loop then include it
if($displayedCategories == ($totalRows - 1 ) ) {
if($grabARecord = mysql_fetch_array ($queryResultHandle)) { // if we can get a last record
$category = stripslashes($grabARecord["category"]);
$listingsInACategory = $grabARecord["LISTINGCOUNT"];
// convert the possibly space filled text into a continuous string
$encodedCategory = urlencode($category);
// generate the hyperlink and the correct search type
echo "<a href=\"" . INSTALLPATH . "result.php?goal=$blahblahblah\">$category" . "</a><br>";
}
}
echo"</td>\n";
++$columnCount; // increment the column counter
} // while
echo "</tr></table>\n";