try this:
$sql = "SELECT * FROM table
  WHERE town LIKE '%$search_data%' ";

if ($reference != "")
  $sql .= "OR whatever";


""James, Yz"" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
93vs2p$cng$[EMAIL PROTECTED]">news:93vs2p$cng$[EMAIL PROTECTED]...
> OK, I got a simple search page working (thanks to all of you who helped
me).
>
> Another simple question for you.  If I had a search  and the data to be
> searched needs to be determined by check boxes, How would I write the
sql>?
> Like this?
>
> $sql = "SELECT * FROM table
>   WHERE town LIKE '%$search_data%' OR street LIKE '%$search_data%' ";
>
> Is "OR" even the correct syntax?  Here's how I tried it, which didn't give
> any results.....
>
> (Where reference is the id number (or map reference) and search_data is
the
> text field for users to tpye the query.
>
> if ($reference != "")
>     $search_reference = "OR id LIKE '%$reference%'";
> }
>
> $sql = "SELECT * FROM table
>   WHERE town LIKE '%$search_data%' $search_reference";
>
> $result = @mysql_query($sql,$connection)
>  or die (mysql_error());
>
> $num = mysql_num_rows($result);
>
>
> TIA,
> James.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to