PHP Website Search And Display Items
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 :
table id="display" an id should be unique. If you iterate over it and still want it to be an id, put display-n instead, n being the unique id of the product for example. (or use class="display" instead of id)
You should take a look at sql injection and how to defeat them.
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 ($search as $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"