Php Website Search And Display Items
I am creating a dummy online store to illustrate some real world functionality which one of them is to search the website for items i.e. I have written PHP code to deal with this
Solution 1:
First, try removing this
while ($query_row = mysql_fetch_row($query_search))
{
echo$query_row['product_name'];
}
I also noticed a few bad typo in your code :
Solution 2:
I might rather do this:
$query = "SELECT product_name FROM products WHERE product_name LIKE %" . $search . "%";
Hope it will help. Then use a foreach loop to run through the result like:
foreach ($searchas$key => $result){
echo$result . '<br />';
}
Solution 3:
mysql_fetch_row( $query_search)
returns a plain array not an associative array but you are trying to access its values using keys -$query_row [ 'product_name' ]
. Rather use_fetch_array
There are lots of syntactical errors. There is a space between function name and list of parameters.
Don't use
mysql_
. They are deprecated (read: dead). Use PDO instead.
Post a Comment for "Php Website Search And Display Items"