Basic SQL syntax
| From: | James, Yz | Date: | Mon, 15 Jan 2001 22:09:35 +0000 |
| Subject: | Basic SQL syntax | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-34691@lists.php.net to get a copy of this message | ||
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.