Re: Basic SQL syntax
| From: | Johannes Janson | Date: | Mon, 15 Jan 2001 22:11:06 +0000 |
| Subject: | Re: Basic SQL syntax | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-34697@lists.php.net to get a copy of this message | ||
try this:
$sql = "SELECT * FROM table
WHERE town LIKE '%$search_data%' ";
if ($reference != "")
$sql .= "OR whatever";
""James, Yz"" <liljim@btconnect.com> schrieb im Newsbeitrag
news:93vs2p$cng$1@toye.p.sourceforge.net...
> 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: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>