| |
|
|
MAJESTIC FLOORING
LLC | OUR SPONSORS
|
|
define('MAX_REC_PER_PAGE_LISTING', 100);
# set up db or die trying
include("sponsors/connector-db.inc.php");
# calculate total records
$rs = mysql_query("SELECT COUNT(*) FROM sponsor_link_category_tbl") or die("Count query error!");
list($total) = mysql_fetch_row($rs);
$total_pages = ceil($total / MAX_REC_PER_PAGE_LISTING);
# calculate our starting point and range...
$page_listing = intval(@$_GET["page_listing"]);
# intval() forces to a numeric value to protect against garbage or malicious entries; intval("string") is ZER0
# @ in front of a variable suppresses warnings if it isn't there, an empy string intval() will be ZERO
if (0 == $page_listing)
$page_listing = 1; # 1-based
$start = MAX_REC_PER_PAGE_LISTING * ($page_listing - 1); # first record we will display
$max = MAX_REC_PER_PAGE_LISTING; # maximum number to show
# query
$result = mysql_query("
SELECT *
FROM sponsor_link_category_tbl
ORDER BY category_name ASC
LIMIT $start, $max -- where the magic happens
") or die("Database query error!");
mysql_close();
$num=mysql_numrows($result);
$cols = 3; // put the number of columns you want here
//$col_width = round(1/$cols * 100,0)."%"; // get column width as %
$extra_cells = "";
//$num_rows=$row_num;
$num_rows = mysql_num_rows($result); // get number of records from query
$extra_needed = $cols-($num_rows % $cols); //find out how many blank cells there will be
if($extra_needed!= $cols ){
for($i = 0; $i<$extra_needed;$i++){
$extra_cells .= " | | \r\n"; // loop the blank cells in
}
}
if($result){
echo ''."\r\n";
$tdcount = 1; //start cell count at one
while($rows=mysql_fetch_assoc($result)){
if($tdcount % $cols == 1) echo "\r\n"; // check to see if new row needs to be started
echo "";
$id=$rows['category_id'];
include("sponsors/connector-db.inc.php");
$query2="SELECT * FROM sponsor_link_tbl where category_id='$id'";
$result2=mysql_query($query2);
$num2=mysql_numrows($result2);
mysql_close();
if ($num2!=0){
echo "";
}
//if ($num2==0){
//$tdcount=$tdcount-1;}
$i=0;
while ($i < $num2) {
$name_of_company=mysql_result($result2,$i,"name_of_company");
$street=mysql_result($result2,$i,"street");
$city=mysql_result($result2,$i,"city");
$state=mysql_result($result2,$i,"state");
$zip_code=mysql_result($result2,$i,"zip_code");
$website=mysql_result($result2,$i,"website_address");
$description=mysql_result($result2,$i,"description");
echo "
";
echo "".$street."";
echo " ".$city.", ";
echo "".$state.", ";
echo "".$zip_code."";
echo " ".$website."";
echo " ".$description." ";
echo " ";
$i++;
}
" | \r\n";
//if ($num2!=0){
if($tdcount == $num_rows) echo $extra_cells; //echo extra cells into row
//}
//if ($num2!=0){
if($tdcount % $cols == 0) echo " \r\n"; // check to see if row needs to be ended
//}
//if ($num2!=0){
$tdcount++; // add one to cell count
//}
}
echo " \r\n";
}
?>
|
| Vote Here! |
|
|
|
|
|
|