warm-water-flies-product.php

Warm Water Flies For Fishing

%d “;

//Format for a page-link, if it links to the current result-page (here it is not a link)
$page_array_format_current_page = “%d “;

//Format for the next-link
$page_next_format = “next→ “;

//Format for the back-link
$page_back_format = “←back “;

//DO NOT CHANGE THIS…
//offset point. Recordsets offset+limit are displayed
$offset = (!empty($_REQUEST[‘offset’])) ? (int)$_REQUEST[‘offset’] : 0;

/**
* Function getPagesArray()
* returns Pages-Array like this:
*
* Array {
* 1 => array {
* ‘page’ => 1,
* ‘page_offset’ => 0
* }
* 2 => array {
* ‘page’ => 2,
* ‘page_offset’ => 10
* }
* }
*
*
* @return array pages-array
*/
function getPageArray($hits, $range)
{
$pages = array();
$hits = (int)$hits;
$range = (int)$range;

//if there are more hits then range allows…
if($hits > $range) {
$page_number = $hits / $range;
$number_of_pages = ceil($page_number);

$offset = 0;
for($i=1; $i<= $number_of_pages; $i++) { $pages[$i] = array('page' => $i, ‘page_offset’ => $offset);
$offset += $range;
}
}
return $pages;
}

function printPageArray($gVars)
{
extract($gVars, EXTR_OVERWRITE);
$offset = (int)$offset;
$hits = (int)$hits;

$pages = getPageArray($hits, $range);
//var_dump($pages);

//get the back-link
if($offset > 0) {
//if that is not the first page
//show the back-link
$back_offset = $offset – $limit;
//should not be smaller then 0 😉
$back_offset = ($back_offset < 0) ? 0 : $back_offset; //print formated back-link printf($page_back_format, $back_offset); } //get the page-links $pagenum = $offset / $limit; for($i=max(1, $pagenum - 4); $i <= min($pagenum + 10, sizeof($pages)); $i++) { if($pages[$i]['page_offset'] == $offset) { //thats the number of current page printf($page_array_format_current_page, $pages[$i]['page']); } else { //not the current page printf($page_array_format, $pages[$i]['page_offset'], $pages[$i]['page']); } } //get the next-link if(($offset + $limit) < $hits) { //if this is not the last page $next_offset = $offset + $limit; printf($page_next_format, $next_offset); } } //do the connection @MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database"); //choose the db @mysql_select_db( "$dbName") or die( "Unable to select database"); //first we need a simple query to get the number of all records $query = "SELECT count(SKU) FROM $userstable WHERE ProductGroup = ' Warm water flies'"; $arrQueryAllRecords = mysql_query($query); $row = mysql_fetch_array($arrQueryAllRecords, MYSQL_NUM); $hits = (int)$row[0]; //Now the real query, but now with LIMIT-Clause $query = "SELECT SalePrice,RetailPrice,BuyLink,ProductGroup,ProductName,LongDescription,ImageURL FROM $userstable WHERE ProductGroup = ' Warm water flies'"; $query.= " LIMIT $offset, $limit"; $result = mysql_query($query) or die(mysql_error()); /* How many of these users are there? */ $number = @mysql_num_rows($result); //FIX!!!!!! /* Print these results to the screen in a nice format */ $gVars = array("page_array_format" => $page_array_format,
“page_array_format_current_page” => $page_array_format_current_page,
“page_back_format” => $page_back_format,
“page_next_format” => $page_next_format,
“offset” => $offset,
“limit” => $limit,
“range” => $limit,
“hits” => $hits
);

$i = 0;

IF ($number == 0) :

//email if no items in the category
IF ($hits == 0):
PRINT “New Product Coming Soon!
“;
$adminEmail = “webmaster@gosalmonfishing.com”;
$subject = “The WHERE ProductGroup = ‘ Warm water flies’ is no longer valid”;
$body = “The category in the subject no longer has products in it. Page warm-water-flies-product.php”;

//mail($adminEmail,$subject,$body,”FROM: $adminEmail”); //not on windows

ELSEIF ($number > 0) :

PRINT “”;

//Now its time to print out our pages-links
PRINT “

“;
//where ever u put next line, there will be displayed the page-array
printPageArray($hits, $limit);
PRINT “

“;

PRINT “

“;
PRINT “

“;

$x = 1;
echo “

“;
//start inside
WHILE ($i < $number): $ImageURL = mysql_result($result,$i,"ImageURL"); $BuyLink = mysql_result($result,$i,"BuyLink"); $ProductName = mysql_result($result,$i,"ProductName"); $LongDescription = mysql_result($result,$i,"LongDescription"); $RetailPrice = mysql_result($result,$i,"RetailPrice"); $SalePrice = mysql_result($result,$i,"SalePrice"); //put td here PRINT '

“;
if ($x == 2 ) {$x ++;} else {
if ($x == 3 ) {$x ++;} else {
if ($x == 4 ) {echo “

“; $x=1;} else{$x ++;}
}}
$i++;

ENDWHILE;
print “

“;
echo “

‘;

PRINT “
“;
PRINT “$ProductName
“;
PRINT “$LongDescription

“;
PRINT “$$RetailPrice
“;
PRINT “$$SalePrice
“;
PRINT “MORE…

“;

//wrap it
//change where its 2,3,4 to 3,4,5 to display five in a row. – easy ha..
print “

“;
echo “

“;
//Now its time to print out our pages-links
PRINT “

“;
//where ever u put next line, there will be displayed the page-array
printPageArray($hits, $limit);
PRINT “

“;

ENDIF;
//if is at end
?>
 

RSS
Follow by Email
Facebook