Skip to main content
Known Participant
November 22, 2009
Question

Mysql search to include part of the parameter

  • November 22, 2009
  • 1 reply
  • 297 views

I currently have search placed such that it will only find the field if we put the exact parameter to search. I like to know the code such that it will find the result as long as the field has some of the character that was searched. for example :  if i search for 143v45 i would like it to find the field with toshiba_143v45.. and here is the code and i am searching the sku

if (isset($_POST['sku'])) {
  $skuid_merchant = (get_magic_quotes_gpc()) ? $_POST['sku'] : addslashes($_POST['sku']);
}
mysql_select_db($database_shoppingsite, $shoppingsite);
$query_merchant = sprintf("SELECT programname, name, description, sku, saleprice, price, retailprice, buyurl, imageurl, startdate, enddate, standardshippingcost FROM %s WHERE programname = '%s' OR sku LIKE '%s'", $vendor_merchant,$vendor_merchant,$skuid_merchant)

This topic has been closed for replies.

1 reply

David_Powers
Inspiring
November 23, 2009

Judging from the first section of the code that you have posted here, you're using an old version of Dreamweaver, so it's difficult to say how you should enter the SQL query in the Recordset dialog box. However, if you change the final section of the code as follows, it should work:

$query_merchant = sprintf("SELECT programname, name, description, sku, saleprice, price, retailprice, buyurl, imageurl, startdate, enddate, standardshippingcost FROM %s WHERE programname = '%s' OR sku LIKE '%s'", $vendor_merchant,$vendor_merchant,'%' . $skuid_merchant . '%')