i have a table with a few fields... id, prodname, description, price
i want the user to be able to search for a product using the "description" field.
can anyone point me in the right direction?
have a form where the user can type what they are searching for
//search.php <form name="search" method="post" action="<?php echo $PHP_SELF ; ?>"> <input type="text" name="description"> <input type="submit> </form> <?php if(isSet($_POST['description'])){ mysql_connect("hostname","username","password"); mysql_connect("database_name"); $q = "select * from tablename where description like '%".$_POST['description']."%'"; echo $q; $r = mysql_query($q); if (mysql_error()){ echo mysql_error(); }else{ if(mysql_num_rows($r)<1){ echo "no records found"; }else{ while($row=mysql_fetch_array($r)){ echo $row['prodname']; } } }
reg kevin