// 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="type";
$show_pc_notes="on";
$show_pc_first="on";
$show_pc_coll="";
$line_break="on";
$show_books="";
$search="";
$type="All";
}
?>
Harlan Ellison Piece Query
// Fix type
IF ($type == "Short") $type = "Short Story";
// End page now if no query active
if($SUBMIT != "Submit Query") {
INCLUDE("html_end.htm");
exit;
}
?>
//Display query results ?>
// Convert ' so we don't screw up query
$search=strtr($search,"'",'"');
// Build query string
$sql = "SELECT * from bib_piece WHERE by_he='1' ";
IF ($search > " ") $sql .= " AND (title LIKE '%$search%' OR notes LIKE '%$search%')";
IF ($type <> "All") $sql .= " AND subType = '$type'";
ELSE $sql .= " AND Type<>'Break'";
$sql .= " ORDER BY ";
IF ($break == "type") $sql .= "Type DESC,";
IF ($sort == "title") $sql .= "alpha_title";
ELSE { IF ($sort == "type") $sql .= "subType, alpha_title";
ELSE $sql .= "first_pub, title";
}
echo $sql;
$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 pieces selected:
";
// Read through titles selected
$story_hdr = "N";
$essay_hdr = "N";
while ($row = mysql_fetch_array($rc)) {
// check for type headers
IF ($break=="type") {
IF ($row[Type]=="Story" && $story_hdr!="Y") {
$story_hdr = "Y";
echo "Harlan Ellison: Stories
\n";
}
IF ($row[Type]=="Essay" && $essay_hdr!="Y") {
$essay_hdr = "Y";
echo "Harlan Ellison: Essays
\n";
}
}
echo "$row[title]     - $row[subType], $row[first_pub]";
IF ($show_pc_coll) {
ECHO " Collected: ";
IF ($row[collected]) echo "Yes";
ELSE echo "No";
}
echo "
\n";
IF ($show_pc_first && $row[first_appearance]>" ")
echo "First Appearance: $row[first_appearance]
\n";
IF ($show_pc_notes && $row[notes]>" ")
echo "  $row[notes]
\n";
// Read books if specified
IF ($show_books) {
$sql = "SELECT * from bib_book,bib_book_piece WHERE piece_id=$row[piece_id] ";
$sql .= "AND bib_book.book_id=bib_book_piece.book_id ORDER by year_pub";
$rc2 = mysql_db_query($database,$sql,$db);
IF (mysql_num_rows($rc2)) echo "Books where piece appears:
\n";
while ($row2 = mysql_fetch_array($rc2)) {
echo "  $row2[title] - $row2[type], $row2[year_pub]
\n";
}
}
// end of read loop on pieces
if ($line_break) echo "
";
}
//end page
INCLUDE("html_end.htm");
exit;
?>