Jump to content

trim blank spaces in search


hyster

Recommended Posts

im having trouble getting trim to work.

on my search form, a scanner is used and for some reason its putting blank spaces in which are added to the search.

where do i put the trim?

ive tried a few different places but didnt work.

 

Thanks for any help

 

// Retrieve data from database 
$search=$_POST['search'];
if ($search == '' || $search == ' '){

echo "Search Field is Empty - Please Input an Spl Number!";
echo "<body style='background:#FC0;'>";
die;
}
else{
// 1st query
$sql="select * from spl WHERE spl1 LIKE TRIM('%$search%') LIMIT 1";
$result=mysql_query($sql) or die (mysql_error());
$rows=mysql_fetch_array($result);
$passon=$rows['orsku'];


//2nd 
$sql1="select * from dsgi WHERE reconsku LIKE '%$passon%'";
$result1=mysql_query($sql1) or die (mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/201831-trim-blank-spaces-in-search/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.