<html>
<head>

<title>Item Selection Page</title>
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">

<?php
include("connect.php");
$query = "SELECT * FROM item ORDER BY itemName";   
$result = $db->query($query);
$num_results = $result->num_rows;

echo "<table border='1' cellpadding='0' cellspacing='0' width='100%'>";

echo "<tr>";
echo "<td colspan='4'>";
echo "Item List";
echo "</td>";
echo "</tr>";
echo "<form name='form' method='post' action=''>";
for ($i=0; $i <$num_results; $i++){
$row = $result->fetch_array();

echo "<tr>";
echo "<td>";
echo $i+1;
echo "</td>";
$num = $i+1;
echo "<td>";
echo "<input type='hidden' name='ISBN".$num."' value='$row[ISBN]'>".$row['ISBN']."";
echo "</td>";

echo "<td>";
echo "<input type='hidden' name='itemName' value='$row[itemName]'>".$row['itemName']."";
echo "</td>";

echo "<td>";
echo "<input type='button' value='Submit' onclick='get_value(ISBN".$num.".value);'>";
?>
<script langauge="JavaScript">
function get_value(num){
opener.document.form.ISBN.value = num;
self.close();
}
</script>
<?php
echo "</td>";
echo "</tr>";

}
echo "</form>";
echo "</table>";
?>
</html>
