getVarInt("pgid",1); // make sure not past ends if ( $pgid<1 ) {$pgid = 1; } if ( $pgid>561 ) {$pgid = 561; } //set previous page if ( $pgid>1 ) { $prev = $pgid - 1; } else { $prev = 1; } // set next page if ( $pgid<561 ) { $next=$pgid + 1; } else { $next = 561; } // get name of book or collection if any (such as FooteSketchesNorthCarolina) // $book = $_GET[book]; // Note: having this in the querystring is mostly for SEO $book = $req->getVarString("book",30,"FooteSketchesNorthCarolina"); $bookdisp = $book; if ($book=="FooteSketchesNorthCarolina") { $bookdisp = "Sketches of North Carolina, Historical and Biographical, Illustrative of the Principles of a Portion of Her Early Settlers. by William Henry Foote (1846)"; } // get bookid (integer) for Foote's Sketches of North Carolina (tbd: generalize) $bookid = 5; // 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 // FooteSketchesNorthCarolina = 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); // build name of annotations file if any $notesn = $path . "notes/".$pgid.".txt"; $sql = "SELECT * FROM pages INNER JOIN chapters ON (pages.intChID = chapters.intChID) WHERE (pages.intPgID=" . $pgid . ") AND (pages.intBookID=5) AND (chapters.intBookID=5) LIMIT 1"; // get data from database $conn = mysql_connect ("localhost", "roanetnh_spadmin", "aO4XpJv9FK"); // assume mysql is working $has_mysql = 1; if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); // mysql not working, save that fact in variable $has_mysql = 0; } if ($has_mysql==1) { if (!mysql_select_db("roanetnh_coll")) { echo "Unable to select database roanetnh_coll: " . mysql_error(); // mysql not working, save that fact in variable $has_mysql = 0; } } if ($has_mysql==1) { $result = mysql_query($sql,$conn); if ($myrow = mysql_fetch_array($result)) { // a row for this pgid was found! get fields.... $k = $myrow["strKeywords"]; $htmlt = $myrow["strHTMLTitle"]; if (strlen($htmlt)==0) { $htmltdisp = ""; } else { $htmltdisp = " - " . $htmlt; } $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 = ""; $pgdispleft = ""; } else { $pgdisp = " - Page " . $pgnum; $pgdispleft = "p. " . $pgnum . ", "; } if (strlen($t)>0) { $t = $pgdispleft . $t . ", " . $bookdisp; } else { $t = $pgdispleft . $chfulltitle . ", " . $bookdisp; } } else { echo "Sorry, no record for page " . $pgid . " found!"; } mysql_close($conn); } else { // here $has_mysql is not 1, that is, something is wrong with the mysql for some reason, so we must recover gracefully $k = ""; $t = ""; $pgnum = ""; $pgdisp = ""; $pgdispleft = ""; $htmltdisp = ""; $chtitle = ""; $chsubt = ""; $chfulltitle = ""; } if ($t=="") { // degrade tile gracefully if no db record, hence no title $pgnumbyhand = $pgid+4; $pgdispbyhand = ""; if ($pgid<4) { $pgnumbyhand = $pgid; } if ($pgid>9) { $pgnumbyhand = $pgid+5; } $appendix = ""; if ($pgid>553) { // appendix is numbered 1 - 8 $pgnumbyhand = $pgid - 553; $appendix = "A"; } if ($pgnumbyhand>0) { $pgdispbyhand = $appendix . $pgnumbyhand . " - "; } $t = "page " . $pgdispbyhand . $bookdisp; } ?> <? echo $t; ?> /> />



Notes Added for this Online Edition:



0)&&($pgid!=3)&&($pgid<553)) { // calculate google books bookmark if ($pgid<10) { // front matter $googlepgid = $pgid+4; $googlebookmark = "PR" . $googlepgid; } else if ($pgid<28) { $googlepgid = $pgid+5; $googlebookmark = "PR" . $googlepgid; } else { // pgid>=numbered $googlepgid = $pgid+5; $googlebookmark = "PA" . $googlepgid; } ?>

Other links about this page of Foote's Sketches of North Carolina: