Hallo, dieses codeschnipsel zeigt die suche in einer mysql
datenbank, jetzt hätt ich gern neben jedem ausgegebenem Titel
eine checkbox zum markieren(wie warenkorb).
was muss ich da einfügen?
MFg
Matthias
datenbank, jetzt hätt ich gern neben jedem ausgegebenem Titel
eine checkbox zum markieren(wie warenkorb).
was muss ich da einfügen?
PHP-Code:
// show search results
if(!empty($sql)) {
if($sqlType=="author") {
// show authors
$result = mysql_query($sql);
if(!$result or !mysql_num_rows($result))
echo "<p>No results.\n";
else {
echo "<hr><ul>\n";
while($row = mysql_fetch_object($result)) {
echo "<li>",
build_href("./find.php",
"sqlType=title&authID=$row->authID",
last_name_last($row->authName)),
"</li>\n";
}
echo "</ul>\n";
}
}
// show titles
elseif($sqlType=="title") {
// just in case it is still here: drop tmpTitleIDs
mysql_query("DROP TABLE IF EXISTS tmpTitleIDs");
// create new table with title IDs
mysql_query($sql);
if(!mysql_affected_rows()) {
echo "<p>No results.\n";
}
else {
// querys for complete title data
$result1 = mysql_query
("SELECT titles.titleID AS titleID, " .
" titles.title AS title, " .
" titles.subtitle AS subtitle, " .
" titles.edition AS edition, " .
" titles.year, " .
" titles.isbn, " .
" titles.comment, " .
" publishers.publName AS publisher, " .
" publishers.publID, " .
" categories.catName AS category, " .
" languages.langName AS language " .
"FROM titles JOIN tmpTitleIDs" .
" LEFT JOIN categories ON titles.catID = categories.catID " .
" LEFT JOIN languages ON titles.langID = languages.langID " .
" LEFT JOIN publishers ON titles.publID = publishers.publID " .
"WHERE titles.titleID = tmpTitleIDs.titleID");
// query for authors
$result2 = mysql_query
("SELECT tmpTitleIDs.titleID, rel_title_author.authID, " .
" authName AS author " .
"FROM authors, rel_title_author, tmpTitleIDs " .
"WHERE authors.authID = rel_title_author.authID " .
" AND rel_title_author.titleID = tmpTitleIDs.titleID " .
"ORDER BY rel_title_author.authNr, authName");
// copy authors into array
while($row = mysql_fetch_object($result2)) {
// seperate authors by a comma
if($authors[$row->titleID])
$authors[$row->titleID] .= ", ";
// add author to author's list; because of ORDER BY clause
// in the SQL statement the authors are ordered correctly
$tmp = build_href("./find.php",
"sqlType=title&authID=$row->authID",
last_name_last($row->author));
$authors[$row->titleID] .= $tmp;
}
// show title list
echo "<hr><ul>\n";
$titlecount=0;
while($row = mysql_fetch_object($result1)) {
$titlecount++;
if($titlecount<=$pagesize) {
if($row->publisher)
$publref = build_href("./find.php",
"sqlType=title&publID=$row->publID",
$row->publisher);
// title
echo "<p><li>", $authors[$row->titleID], ": ",
"<b>", htmlentities($row->title), "</b>",
$row->subtitle ? ", " . htmlentities($row->subtitle) . " " : "",
$row->publisher || $row->year ? "<br>" : "",
$row->publisher ? $publref : "",
$row->year ? ", " . htmlentities($row->year) . " " : "",
$row->edition ? "<br>Edition: " . htmlentities($row->edition) ." " : "",
$row->isbn ? "<br>ISBN: " . htmlentities($row->isbn) . " " : "",
$row->language ? "<br>Language: <i>" . htmlentities($row->language) . "</i> " : "",
$row->category ? "<br>Category: <i>" . htmlentities($row->category) . "</i> " : "",
$row->comment ? "<br>Comment: <i>" . htmlentities($row->comment) . "</i> " : "",
"</li>\n";
}
}
echo "</ul>\n";
} // else block for if(!mysql_affected_rows())
// drop temporary database
mysql_query("DROP TABLE IF EXISTS tmpTitleIDs");
// show links to other pages
if((isset($page) and $page>1) or $titlecount>$pagesize) {
echo "<hr>\n";
$query = "sqlType=title";
$query .= isset($authID) ? "&authID=$authID" : "";
$query .= isset($publID) ? "&publID=$publID" : "";
$query .= isset($search) ? "&search=" . urlencode($search) : "";
echo "<p>More results: ";
// links to previous pages
if(isset($page) and $page>1) {
echo build_href("./find.php",
$query . "&page=" . ($page-1),
"Previous page");
echo " / Page ";
for($i=1; $i<$page; $i++) {
if($i>1) echo " ";
echo " ",
build_href("./find.php", $query . "&page=" . $i, $i);
}
}
// current page
if($page>1)
echo " ";
else
echo "Page ";
echo "<b>($page)</b> ";
if($titlecount>$pagesize) {
if(isset($page))
echo " ";
else
$page=1;
echo build_href("./find.php", $query . "&page=" . ($page+1), ($page+1));
echo " / ";
echo build_href("./find.php",
$query . "&page=" . ($page+1),
"Next page");
}
echo "\n";
}
}
}
Matthias
Kommentar