getVarInt("pgid",1); // make sure not past ends if ( $pgid<1 ) {$pgid = 1; } if ( $pgid>557 ) {$pgid = 557; } //set previous page if ( $pgid>1 ) { $prev = $pgid - 1; } else { $prev = 1; } // set next page if ( $pgid<557 ) { $next=$pgid + 1; } else { $next = 557; } // get name of book or collection if any (such as WaddellsAnnals) // $book = $_GET[book]; // Note: having this in the querystring is mostly for SEO $book = $req->getVarString("book",30,"WaddellsAnnals"); $bookdisp = $book; if ($book=="WaddellsAnnals") { $bookdisp = "Waddell's Annals of Augusta County, Virginia, from 1726 to 1871"; } // get bookid (integer) for Waddells (tbd: generalize) $bookid = 1; // get name of location = folder holding current page // = 0 for pages up through 99, 1 for pages 100-199, etc. // calculate this numeric value for Waddell = pageID with last two digits removed: $pgbin = (int) ($pgid/100); if ($pgid<100) { $loc="0"; } else { $loc = strval($pgbin); } // build path to file from book and location $path = "books/"; if ($book!="") {$path = $path . $book . "/";} if ($loc!="") {$path = $path . $loc . "/";} // build name of text file if any $txtn = $path . "txt/".$pgid.".txt"; $txtnexists = file_exists($txtn); $sql = "SELECT * FROM pages INNER JOIN chapters ON pages.intChID = chapters.intChID WHERE (pages.intPgID=" . $pgid . ") AND (pages.intBookID=1) AND (chapters.intBookID=1) LIMIT 1"; // get data from database $conn = mysql_connect ("localhost", "roanetnh_spadmin", "aO4XpJv9FK"); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("roanetnh_coll")) { echo "Unable to select database roanetnh_coll: " . mysql_error(); exit; } $result = mysql_query($sql,$conn); if ($myrow = mysql_fetch_array($result)) { // a row for this pgid was found! get fields.... $k = $myrow["strKeywords"]; $t = $myrow["strHTMLTitle"]; $chtitle = $myrow["strChTitle"]; $chsubt = $myrow["strChSubT"]; if (strlen($chsubt)==0) { $chfulltitle = $chtitle; } else { $chfulltitle = $chtitle . ": " . $chsubt; } $pgnum = $myrow["strPgNum"]; if (strlen($pgnum)==0) { $pgdisp = ""; } else { $pgdisp = " - Page " . $pgnum; } if (strlen($t)>0) { $t = $t . " - " . $chfulltitle . $pgdisp . ", " . $bookdisp; } else { $t = $chfulltitle . $pgdisp . ", " . $bookdisp; } } else { echo "Sorry, no record for page " . $pgid . " found!"; } mysql_close($conn); ?> <? echo $t; ?>