[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-db
Subject:    [PHP-DB] Re: adding a space in mysql
From:       65.215.244.52
Date:       2002-07-31 23:06:52
[Download RAW message or body]



Ron Wallace wrote:
> thanks, helpers, but I think I have a simple solution:
>  I will insert a space at the front of the string,
> where the db must accept and retain it.
> 
> BTW, here is the SQL I am working with:
> //////////////////////////////////////////
> elseif ($desc==desc) {
>   $sql="SELECT bandid, bandname, bandesc, bin_id,
> genre
>   FROM bands, genre WHERE
> (bands.genreid=genre.genreid) AND ";
> 
>   while (list($key, $word)=each($wordsarray)) 
> //$wordsarray from textbox input
>      { 
>         $sql=$sql."(bandname LIKE '$word %' OR 
>                          bandname LIKE '% $word %' OR 
>                          bandname LIKE '% $word' OR 
>                          bandesc LIKE '$word%' OR 
>                          bandesc LIKE '% $word %' OR 
>                          bandesc LIKE '% $word' OR 
>                          genre LIKE '$word%' OR 
>                          genre LIKE '% $word') AND "; 
>       }
> $sql=substr($sql, 0, (strlen($sql)-5));
> $sql=$sql."  ORDER BY genre.genre ASC, bandname ASC";
>                            }
> ///////////////////////////////////////////////////
> If I do "bandname='$var' I would not hit the band 'Red
> Letter Day' if the user jusr types 'red'.

Howerver if bandname was 'My name is Fred'
you will get a hit, because it is LIKE '$word%'
where Fred ends with 'red';


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic