<?php
include_once 'pageRedirect.php';
include_once 'redirect.php';
include_once 'error.php';
session_start();
if(!$_SESSION['Name'])
{
echo "You do not have permission to view this page.";
exit();
}
function Output_Entries() {
/*Make the connection to the database. The syntax is
odbc_connect( 'SYSTEM_DSN' , 'USER', 'PASSWORD' );
$cnx will hold the
pconnect is used to establish a persistent database
connection to the Database until the procedure is completed. */
$cnx = odbc_connect( 'project_draft', 'root', '' );
if (!$cnx) {
Error_handler( "Error in odbc_connect" , $cnx );
}
// send a simple odbc query . returns an odbc cursor
$cur= odbc_exec( $cnx, "select * from BookSpec where BookSpec.Coursecode = '$_POST[search]'" );
if (!$cur) {
Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
}
echo "<table border=1><tr><th>PersonID</th><th>BookID</th><th>Course</th>".
"<th>Author</th><th>Title</th>".
"<th>Price</th><th>Edition</th>".
"<th>DateListed</th><th>Hardcover</th>".
"<th>Bought</th><tr>\n";
$nbrow=0; //Local variable to count number of rows
// fetch the succesive result rows
while( odbc_fetch_row( $cur ) ) {
$nbrow++;
$PostedBy= odbc_result( $cur, 1 ); // get the field "PersonID"
$BookSpecID= odbc_result( $cur, 2 ); // get the field "Title"
$CourseCode= odbc_result( $cur, 3 ); // get the field "FamilyName"
$Author= odbc_result( $cur, 4 ); // get the field "GivenName"
$Title= odbc_result( $cur, 5 ); // get the field "PreferredName"
$Price= odbc_result( $cur, 6 ); // get the field "Password"
$Edition= odbc_result( $cur, 7 ); // get the field "DateOfBirth"
$DateListed= odbc_result( $cur, 8 ); // get the field "Mobile"
$Hardcover= odbc_result( $cur, 9 ); // get the field "DateExpired"
$Bought= odbc_result( $cur, 10); // get the field "FirstJoined"
echo "<tr><td>$PostedBy</td><td>$BookSpecID</td>".
"<td>$CourseCode</td><td>$Author</td>".
"<td>$Title</td><td>$Price</td>".
"<td>$Edition</td><td>DateListed</td>".
"<td>Hardcover</td><td>Bought</td><tr>\n";
}
echo "<tr><td colspan=2>$nbrow entries </td></tr></table>";
// close the connection. important if persistent connection are "On"
odbc_close( $cnx);
}
Output_Entries();
?>
same basic code I've used for the login function with sessions etc that does work with the mouse click
html that calls it is just
<html>
<head>
<title>Find</title>
</head>
<body bgcolor="#FFFFFF">
<table border="0">
<tr>
<td>Search</td>
<td><form action="found.php" method="POST">
<p><input type="text" size="20" name="search"></p>
</td>
<td><input type="submit" name="search" value="Find"></td>
</tr>
</table></form>
</body>
</html>