473,395 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Developing a search field

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!

Jan 11 '06 #1
3 1192
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!


we definitely need more information. What are the fields you are searching?
what are people searching for?
Jan 11 '06 #2
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/...xt-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!
Jan 11 '06 #3
Also check out soundex() in mysql documentation.

In a query : SELECT first_name FROM people WHERE soundex( first_name )
= soundex( 'mark' )

will return something like the following
marcus
marko
.... (more)

Don't forget your 'like' queries as well...
SELECT first_name FROM people WHERE first_name LIKE 'mar%'

will return everything starting with 'mar'

You can also wrap strings for LIKE using '%string%' and '%string'

If you're interested in performance, text searching does take a bit of
computing power, so take that into consideration.

Jan 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alastair | last post by:
Hello guys, I've been building a search facility for an intranet site I'm part of developing and we've been building a search engine using Index Server. It mostly works, however there have been...
8
by: Steph | last post by:
Hi. I'm very new to MS Access and have been presented with an Access database of contacts by my employer. I am trying to redesign the main form of the database so that a button entitled...
7
by: John | last post by:
hi, i have created a search form, and i want to search for a specific item in a field. e.g. i have a field called colour, which has record1 = 'red, blue, green' and another record2 = 'red' ...
3
by: Sheau Wei | last post by:
This is the search engine code that i create, but it was error and didnt come out the result. Cn u help me to check what wrong with my code? Thanks <Table cellspacing=1 cellPadding=1...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.