I have PHP installed on Windows 2000 with IIS 5.0. I have MySQL installed as well. I have a php page with 1 input text box and a submit button. I would like to query the MySQL database to pull the records with that data specified by the user. I would like the output sorted by "date". I get undefined variable and it does nothing. Here is my code: for the search page
<head>
<title>Scrip Search</title>
</head>
<body>
<h1>Scrip Search</h1>
<form action="results.php" method="post">
Enter Family Number:<br>
<input name="fnum" type=text>
<br>
<input type=submit value="Search">
</form>
</body>
here is my code for the output page.
<head>
<title>Scrip Search Results</title>
</head>
<body>
<h1>Scrip Search Results</h1>
<?
if (!$fnum)
{
echo "You have not entered search details. Please go back and try again.";
exit;
}
$fnum = addslashes($fnum);
@ $db = mysql_pconnect("xxxx", "xxxx", "xxxxx");
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
mysql_select_db("scrip");
$query = "select * from books where '%".$fnum."%'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo "<p>Number of records found: ".$num_results."</p>";
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<p><strong>".($i+1).". Date: ";
echo stripslashes($row["date"]);
echo "</strong><br>Amount: ";
echo stripslashes($row["amount"]);
echo "</p>";
}
?>
</body>
CAN ANYONE HELP? Thank in advance !!