// Login to database
$hostname="db30.pair.com";
$username = "wyattr_r";
$password = "Elliread23";
$db = mysql_pconnect($hostname,$username,$password);
$database="wyattr_ellison";
// Set form values if first load or reset
IF ($SUBMIT != "Submit Query") {
$sort="title";
$break="role";
$show_role="";
$show_unc="on";
$show_comm="on";
$show_pieces="on";
$show_pc_notepc="on";
$show_pc_noteed="on";
$show_pc_first="";
$show_pc_by="";
$show_editions="";
$show_ed_alt="";
$show_ed_note="on";
$show_all="";
$line_break="on";
$search="";
$type="All";
}
?>
Harlan Ellison Book Query
// Fix type
IF ($type == "Story") $type = "Story Collection";
IF ($type == "Essay") $type = "Essay Collection";
IF ($type == "Mixed") $type = "Mixed Collection";
IF ($type == "Book") $type = "Book Collection";
IF ($type == "Graphic") $type = "Graphic Novel";
// End page now if no query active
if($SUBMIT != "Submit Query") {
INCLUDE("html_end.htm");
exit;
}
?>
//Display query results ?>
// Convert ' to " so we don't screw up query
$search=strtr($search,"'",'"');
// Build query string
$sql = "SELECT * from bib_book WHERE book_id > 0";
IF ($search > " ") $sql .= " AND title LIKE '%$search%'";
IF ($type <> "All") $sql .= " AND Type = '$type'";
$sql .= " order by ";
IF ($break == "role") $sql .= "role DESC,";
IF ($sort == "title") $sql .= "alpha_title";
ELSE { IF ($sort == "type") $sql .= "type, alpha_title";
ELSE $sql .= "year_pub, title";
}
$rc = mysql_db_query($database,$sql,$db);
if(!$rc OR mysql_num_rows($rc) == 0) {
?>
Sorry, no entries were found matching the criteria you selected. Come again!
INCLUDE("html_end.htm");
exit;
}
// Show results count
$numrows = mysql_num_rows($rc);
ECHO "$numrows books selected:
";
// Read through titles selected
$writer_hdr = "N";
$editor_hdr = "N";
while ($row = mysql_fetch_array($rc)) {
// check for role headers
IF ($break=="role") {
IF ($row[role] == "Writer" && $writer_hdr!="Y") {
$writer_hdr = "Y";
echo "Harlan Ellison: Works as Writer
\n";
}
IF ($row[role] == "Editor" && $editor_hdr!="Y") {
$editor_hdr = "Y";
echo "Harlan Ellison: Works as Editor
\n";
}
}
echo "$row[title] - $row[type], $row[year_pub]
\n";
IF ($show_role=="on" || $show_unc == "on") {
IF ($show_role) echo "Role: $row[role] ";
IF ($show_unc) {
echo "Contains previously uncollected work: ";
IF ($row[uncollected]) echo "Yes";
ELSE echo "No";
}
echo "
\n";
}
IF ($show_comm && $row[comments]>" ") echo "  $row[comments]
\n";
IF ($show_comm && $row[notes] > " ") echo "  $row[notes]
\n";
// Read pieces if specified
IF ($show_pieces) {
$sql = "SELECT * from bib_book_piece,bib_piece WHERE book_id=$row[book_id] AND ";
$sql .= "bib_book_piece.piece_id = bib_piece.piece_id ORDER BY sequence";
$rc2 = mysql_db_query($database,$sql,$db);
IF (mysql_num_rows($rc2)) echo "Pieces:
\n";
while ($row2 = mysql_fetch_array($rc2)) {
// Special coding for sections
IF ($row2[subType] == "Section") echo "$row2[title]
\n";
ELSE {
echo "$row2[title]     - $row2[subType], $row2[first_pub]";
IF ($show_pc_by) {
echo " By HE: ";
IF ($row2[by_he]) echo "Yes";
ELSE echo "No";
}
echo "
\n";
IF ($show_pc_first && $row2[first_appearance]>" ")
echo "First Appearance: $row2[first_appearance]
";
IF ($show_pc_notepc=="on" && $row2[15]>" ")
echo "  $row2[15]
\n";
IF ($show_pc_noteed=="on" && $row2[3]>" ")
echo "  $row2[3]
\n";
}
}
}
// Read editions if specified
IF ($show_editions) {
$sql = "SELECT * from bib_edition WHERE book_id=$row[book_id] ORDER BY year_published" ;
$rc2 = mysql_db_query($database,$sql,$db);
IF (mysql_num_rows($rc2)) echo "Editions:
\n";
while ($row2 = mysql_fetch_array($rc2)) {
echo "$row2[publisher]";
IF ($row2[where_pub] > " ") ECHO ", $row2[where_pub]";
echo " - $row2[year_published]   $row2[type] ";
IF ($row2[ISBN] > " ") echo "  ISBN: $row2[ISBN] ";
echo "
\n";
IF ($show_ed_alt && $row2[alt_title]>" ")
echo "  Alternate Title: $row2[alt_title]
\n";
IF ($show_ed_note && $row2[notes]>" ")
echo "  $row2[notes]
\n";
}
}
// end of read loop on books
IF ($line_break) echo "
\n";
}
// Show Uncollected works if specified
IF ($show_all) {
$sql = "SELECT * from bib_piece WHERE (collected='0')";
$sql .= "ORDER by Type DESC, first_pub";
$rc = mysql_db_query($database,$sql,$db);
if(!$rc) {
INCLUDE("html_end.htm");
exit;
}
$story_hdr = "N";
$essay_hdr = "N";
while ($row = mysql_fetch_array($rc)) {
// check for type headers
IF ($row[Type] == "Story" && $story_hdr!="Y") {
$story_hdr = "Y";
echo "
UNCOLLECTED STORIES
\n";
}
IF ($row[Type] == "Essay" && $essay_hdr!="Y") {
$essay_hdr = "Y";
echo "
UNCOLLECTED ESSAYS
\n";
}
// Special coding for sections
IF ($row[subType] == "Section") echo "$row[title]
\n";
ELSE {
echo "$row[title]     - $row[subType], $row[first_pub]
\n";
IF ($show_pc_first && $row[first_appearance]>" ")
echo "First Appearance: $row[first_appearance]
\n";
IF ($show_pc_notepc=="on" && $row[15]>" ")
echo "  $row[15]
\n";
}
// end of read loop on uncollected pieces
}
// end of check on display uncollected pieces
}
//end page
INCLUDE("html_end.htm");
exit;
?>