<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>isbn search</title>
<script type="text/javascript">
function fillterm()
{
typeofsearch = 1003
switch(document.searchform.whichsearch.selectedIndex)
{
case 0:typeofsearch=1003;break;
case 1:typeofsearch=4;break;
case 2:typeofsearch=7;break;
case 3:typeofsearch=1036;break;
}
document.searchform.term.value = "@attr 1="+typeofsearch+" "+document.searchform.term.value;
document.searchform.submit();
}
</script>
</head>
<body onload="document.searchform.term.value=''">
<?php
$host = $_POST['host'];
$term = $_POST['term'];
$num_hosts = count($host);
if (empty($term) || count($host) == 0)
{
echo '<form method="get">
<input type="checkbox" name="host[]" value="bagel.indexdata.dk/gils">
GILS test
<input type="checkbox" name="host[]" value="melvyl.cdlib.org/CDL90" checked="1">
MELVYL
<input type="checkbox" name="host[]" value="z3950.loc.gov:7090/voyager" checked="1">
LoC
<br>
RPN Query:
<input type="text" size="30" name="term">
<input type="submit" name="action" value="Search">
';
}
Search in:<select name="whichsearch"><option value="1">Author</option>
<option value="2">Title</option>
<option value="3">ISBN</option>
<option value="4">Author/Title/Subject</option>
</select>
<BR>
Search: <input type="text" size="30" name="term" value="">
<input type="button" name="action" onclick="fillterm()" value="Search">
<?php
}
else
{
/*
$host = array();
$host[] = "z3950.loc.gov:7090/voyager";
$host[] = "bagel.indexdata.dk/gils";
$host[] = "melvyl.cdlib.org/CDL90";
$num_hosts = count($host);
$term = $_GET["title"];
$term = "@attr 1=1036 " . $term;
*/
echo 'You searched for ' . htmlspecialchars($term) . '<br>';
for ($i = 0; $i < $num_hosts; $i++) {
$id[] = yaz_connect($host[$i]);
yaz_syntax($id[$i],"sutrs");
yaz_search($id[$i],"rpn",$term);
}
yaz_wait();
for ($i = 0; $i <$num_hosts; $i++)
{
echo '<hr>' . $host[$i] . ":";
$error = yaz_error($id[$i]);
if (!empty($error))
{
echo "Error: $error";
}
else
{
$hits = yaz_hits($id[$i]);
echo "Result Count $hits";
}
if($rec=="")
{
$rec="Error: No matching documents were found.\nError: Please try searching again.";
$hits=1;
}
for($p = 1; $p <= $hits; $p++)
{
if (empty($rec)) continue;
//Splitting every seperate line in the search result.
$result1 = explode("\n", $rec);
$result2 = "";
$previous = "xxxxxxxxxx";
$counter=0;
//Keep looping untill the array returns empty and we've processed
//everything from the search record.
for($counter=0;$counter < sizeof($result1);$counter++)
{
//Split each line at the : followed by a tab
$result2 = explode(":\t",$result1[$counter]);
//If there are multiple lines of the same name(E.G. Note)
//Then add the next line to the already existing entry
//after a whitespace, or else just make a new entry in
//the array.
if($result2[0]==$previous)
{
$REC_["$p"]["$result2[0]"].= "\n".$result2[1];
}
else
{
$REC_["$p"]["$result2[0]"].=$result2[1];
}
$previous = $result2[0];
}
}
}
// } The above if has been commented
$resultstogo = count($REC_);
?>
<TABLE border=1 cellspacing=0 cellpadding=0>
<form name="displayresult" action="editmovie.php" method="post">
<input type="hidden" name="Author">
<?php
for($c=1;$c<$resultstogo;$c++)
{
echo "<TR><TD>"
."<TABLE border=0 cellspacing=0 cellpadding=0>"
."<TR><TD><B>Author:</B></TD><TD>".$REC_["$c"]["Author"]."</TD></TR>"
."<TR><TD><B>Title:</B></TD><TD>".$REC_["$c"]["Title"]."</TD></TR>"
."<TR><TD><B>ISBN:</B></TD><TD>".$REC_["$c"]["ISBN"]."</TD></TR>"
."</TABLE>"
."</TD><TD><input type=\"button\" onclick=\"selectresult($c);\" value=\"Add to library\"></TD></TR>";
}
echo "<table>";
?>
print_r($REC_);
<br>
</body>
</html>