<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<?php

$element 
$_GET['element'] ? $_GET['element'] : 'F';
$syntax $_GET['syntax'] ? $_GET['syntax'] : 'MARC21';
$attr $_GET['attr'] ? $_GET['attr'] : '1016';
$q $_GET['q'] ? $_GET['q'] : 'ibsen, henrik';
$format $_GET['format'] ? $_GET['format'] : 'string';

?>
 
<html>
<head>
<title>Z39.50: <?php echo("element=$element, syntax=$syntax, attr=$attr, q=\"$q\", format=$format"); ?></title>
</head>
<body>

<form method="get">
element: <input type="text" value="<?php echo($element); ?>" name="element" /><br />
syntax: <input type="text" value="<?php echo($syntax); ?>" name="syntax" /><br />
attr: <input type="text" value="<?php echo($attr); ?>" name="attr" /><br />
Søk: <input type="text" value="<?php echo($q); ?>" name="q" /><br />
format: <input type="text" value="<?php echo($format); ?>" name="format" /> raw, string, xml<br />
<input type="submit" value="Søk" />
</form>

<?php 

$host 
'torfeus.deich.folkebibl.no:9999/biblios';
$id yaz_connect($host);
yaz_element($id$element);
yaz_syntax($id$syntax);
yaz_range($id110);
yaz_search($id"rpn"'@attr 1=' $attr ' "' $q '"');
yaz_wait();
echo 
"<hr /> $host: \n";
$error yaz_error($id);

if (!empty(
$error)) {

  echo 
"Error: $error \nError number: " yaz_errno($id) . "\n";

} else {

  
$hits yaz_hits($id);
  echo 
"Result Count $hits";
    
    echo 
'<dl>';
  for (
$p 1$p <= 10$p++) {
  
$rec yaz_record($id$p$format);
  if (empty(
$rec)) continue;
    echo 
"<dt><b>$p</b></dt><dd>";
    echo 
nl2br($rec);
    echo 
"</dd>";
  }
  echo 
'</dl>';
    
}

?>

<hr />
<p><a href="yaz.txt">Kildekode</a></p>

</body>
</html>