Hi,
I have completed a website, all apart from one aspect of the site, an ID number search.
What I want it to do is just match the ID typed into the box in a form, then diaplay a single result on a different page.
Please visit the site: http://www.head4themed-homes.co.uk for an idea of what I want the search to do.
I am using PHP version 5.1.2 and MySql Version 5.0.18.
The ID number is the primary key in the database.
I've tried various ways but without success.
Help anybody??
The HTML Form:
<form name="search" method="post" action="results.php">
Enter an ID Number: <input type="text" name="find" />
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Search" />
</form>
The PHP Code is:
<?php
//This is only displayed if they have submitted the form
if ($searching =="yes")
{
echo "Results<p>";
//If they did not enter a search term we give them an error
if ($find == "")
{
echo "<p>You forgot to enter an ID Number, Please try again.";
exit;
}
// Otherwise we connect to our Database
require("inc/conn.php");
// Make the query.
$sql = "SELECT * FROM tbl WHERE ID ='%$find%'";
$result = mysql_query ($sql); // Run the query.
echo '<table align="center" cellspacing="0" cellpadding="5" border="0" width="100%">
';
// Fetch and print all the records.
$bg = '#ffffff'; // Set the background color.
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<tr bgcolor="' . $bg . '" class="style1">
<td align="left" valign="middle"><img src="' . $row['image_link'] .'" width="401px" height="301px"></td>
<td align="left" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td align="left" valign="top" class="style5">Property ID: <b> ' . $row['propertyID'] . '</b><br> Priced From: <b>€ ' . $row['price'] . '</b><br>
Type: <b> ' . $row['type'] . '</b><br>Name: <b>' . $row['name'] . '</b><p>
Area: <b> ' . $row['area'] . '</b><br>
Bedrooms: <b> ' . $row['bedrooms'] . '</b> :: Bathrooms: <b> ' . $row['bathrooms'] . '</b><p>
Pool:<b> ' . $row['pool'] . '</b> :: Garden:<b> ' . $row['garden'] . '</b> :: parking:<b> ' . $row['parking'] . '</b><p><br></td></tr>
<tr><td align="left" valign="top" class="style1">' . $row['description'] . '
</td>
</tr></table>
';
}
echo '</table>';
mysql_free_result ($result); // Free up the resources.
mysql_close(); // Close the database connection.
}
?>
The result is a blank page??
Do not even get an error or the programmed error..