|
Posted by Pedro Graca on 01/12/06 01:17
Rachelle wrote:
> I'm developing a webpage interface for the employees I work with that
> will allow them to search the database for things. I have everything
> else set up, but i'm having problems actually developing the search
> script.... basically my select statement. Anyone with examples of how
> to do this would be appreciated. Thanks!
I use something a lot like this when searching for data in several
different database columns:
<?php
$sql = "select name, city, age from people where 1=1";
if (isset($_POST['has_name'])) $sql .= " and name='{$_POST['name']}'";
if (isset($_POST['has_city'])) $sql .= " and city='{$_POST['city']}'";
if (isset($_POST['has_age'])) $sql .= " and age='{$_POST['age']}'";
?>
If you want to search text within specific columns
try using Full-Text Search functions
http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html
Maybe you'd like to post to comp.databases.mysql for a more
comprehensive answer (mine is [slightly] off topic here).
--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Navigation:
[Reply to this message]
|