Hi Im trying to make a search feature for a site in php that uses a mysql data base. I want to be able to search the whole data base, I have 11 fields, the search word entered in via a form. So far I have the following codes,
this is the code in the search.php page which is the return page from the form,
CODE
<?php
$searchf = $_POST["searchf"];
function testsearch()
{
$result = mysql_query("SELECT * FROM stocklist LIKE $searchf");
while($row = mysql_fetch_array($result))
{
echo $row['make']." ".$row['model']." ".$row['title'] ." ".$row['price'];
echo "<br />";
}
}
testsearch();
?>
This is the form code that on the ;
CODE
<form action="search.php" target="mainFrame" method="post">
Search: <input type="text" name="searchf" />
<input type="submit" />
</form>
The main problem I am having at the moment is i get this error message,
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Group\Apache2\htdocs\Rising sun\search.php on line 20
I cant figure out why it wont work its sending me mad.
Firstly will the code work? Is it just about changing the mysql_fetch_array for another command? I have other mysql querys running and they work fine. Any help or idea will be hugly appresated.
Thanks.