($numbless-1))) $starter = 0;
} else {
$starter = 0;
}
// Set the next and back values
if($starter > ($increment - 1)){
$startnext = $starter + $increment;
$startprev = $starter - $increment;
} else {
$startnext = $starter + $increment;
$startprev = 0;
}
$query = "SELECT * FROM blessings where published = 'Y' and display = 'Y' ORDER BY publishOn DESC LIMIT $starter, $increment";
$fred = mysql_query($query) or die ("could not execute query");
if((mysql_num_rows($fred) == 0)&&(empty($_REQUEST["error"]))) {
header("Location: http://www.tweetedblessings.com/archive.html?error=no_rows");
} elseif (mysql_num_rows($fred) == 0) {
dumpit("We seem to be having a persistent database connection error. 2xError: " . $_REQUEST["error"]);
}
// let's make the 1 2 3 4... nav bar
/* figures out the number of pages: if there's a remainder on the division of the number of
blessings by the increment value, then the number of pages is the blessings / increment rounded up to the next highest integer. If the remainder is 0, then it's the integer value of the division. The current page is the start value divided by the increment + 1 */
$tpages = (($numbless % $increment) > 0) ? ceil($numbless / $increment) : intval($numbless / $increment);
$curpage = floor($starter/$increment) + 1;
// set the range of pages to click
if($curpage < 6){
$begval = 1;
$endval = ($tpages > 10) ? 10 : $tpages;
} else {
$begval = $curpage - 5;
$endval = ($tpages > ($curpage + 5)) ? $curpage + 5 : $tpages;
}
// make the range string
$rangestring = "";
for($i = $begval; $i <= $endval; $i++){
$stval = ($i-1) * $increment;
if($i == $curpage){
$rangestring .= "$i ";
} else {
$rangestring .= "$i ";
}
}
$maxrange = ($tpages -1) * $increment;
$arnav = "PAGE: $rangestring out of $tpages";
// build the list of blessings
$totalbits = mysql_num_rows($fred);
$blessingblock = "";
while($blessinginfo = mysql_fetch_array($fred)){
$photo = "/sitimg/tr/" . $blessinginfo["photoFile"] . ".150.jpg";
$urlSlug = $blessinginfo["urlSlug"];
$shortTitle = $blessinginfo["shortTitle"];
$blessingblock .= <<
EOM;
}
// make the ad block
$adblock ="";
if(($totalbits > 3)&&($totalbits < 8)){
$adblock = $archive160[0] . "\n\n
\n\n" . $archivelu[0];
} elseif ($totalbits > 7) {
$adblock = $archive160[0] . "\n\n
\n\n" . $archivelu[0] . "\n\n
\n\n" . $archive160[1] . "\n\n
\n\n" . $archivelu[1];
}
$pbcontent = <<
$arnav
$blessingblock
$adblock
$arnav
EOM;
include("/home/tweetypi/public_html/modil/pagebase.php");
echo $pagebase;
exit;
function dumpit($error){
// GOOD HOUSEKEEPING
global $dbconnect;
mysql_close($dbconnect);
//PASS THEM ON TO THE 404 WITH THE ERROR MESSAGE
$ugh = urlencode($error);
$url = "http://tweetedblessings.com/404.html?error=$ugh";
header( "HTTP/1.1 404 Not Found" );
header( "Location: " . $url );
exit;
}
?>