getVarInt("pgid",1); // make sure not past ends if ( $pgid<1 ) {$pgid = 1; } if ( $pgid>397 ) {$pgid = 397; } //set previous page if ( $pgid>1 ) { $prev = $pgid - 1; } else { $prev = 1; } // set next page if ( $pgid<397 ) { $next=$pgid + 1; } else { $next = 397; } $txtdir = "txt"; // get name of book or collection if any (such asKercheval-Valley-of-Virginia) // $book = $_GET[book]; // Note: having this in the querystring is mostly for SEO $book = $req->getVarString("book",45,"Kercheval-Valley-of-Virginia"); $bookdisp = "A History of the Valley of Virginia by Samuel Kercheval (1833; 3rd ed. 1902)"; // get bookid (integer) for Kercheval-Valley-of-Virginia (tbd: generalize) $bookid = 7; // 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 // Kercheval-Valley-of-Virginia = 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 . $txtdir . "/".$pgid.".txt"; $txtnexists = file_exists($txtn); // build name of annotations file if any $notesn = $path . "notes/".$pgid.".txt"; // build name of links file if any $linksn = $path . "links/".$pgid.".txt"; $sql = "SELECT * FROM pages INNER JOIN chapters ON (pages.intChID = chapters.intChID) WHERE (pages.intPgID=" . $pgid . ") AND (pages.intBookID=7) AND (chapters.intBookID=7) 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+1; $pgdispbyhand = ""; $appendix = ""; if ($pgid>32) { // appendix is numbered 1 - up = extra pages after main body of a briefe and true report $pgnumbyhand = $pgid - 32; $appendix = "A"; } if ($pgnumbyhand>0) { $pgdispbyhand = $appendix . $pgnumbyhand . " - "; } $t = "page " . $pgdispbyhand . $bookdisp; } ?> <? echo $t; ?>



Notes Added for this Online Edition:





Other links about this page: