You are here: Re: Developing a search field « PHP Programming Language « IT news, forums, messages
Re: Developing a search field

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация