473,386 Members | 1,738 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,386 software developers and data experts.

database entries search

I need help on database entry search.

I am developing an inventory system. And I want a user to be able to search based on words/keywords that they will input in a textbox.

Could anybody give suggestions? Thanks in advance.
Oct 11 '07 #1
4 1445
nathj
938 Expert 512MB
I need help on database entry search.

I am developing an inventory system. And I want a user to be able to search based on words/keywords that they will input in a textbox.

Could anybody give suggestions? Thanks in advance.
backups2007,

The lowtech solution is to have a form which allows the user to search the inventory, post the information to a search results page. This page tests the information from the form and then, if it's good executes a search on the database displaying any selected results.

The Form
[html]
<form id="searchForm" action="searchresults.php" method="post">
<input type="text" size="20" id ="searchText"name="searchText"/>
<input type="submit" id="SearchButton" value="Search" />
</form>
[/html]

The PHP
[php]
<?php
// test the data
if(!empty($_POST['searchText']))
{
// search the database
}
[/php]

This should give you a starting point, I do not know your data structure so you'll have to put in the SQL. But then it's a case of echoing out the results or displaying a message saying there are no matches.

Cheers
nathj
Oct 15 '07 #2
ronverdonk
4,258 Expert 4TB
Searching the database in a simple SQL stetement using regular expressions:
[php]
$sql = "SELECT * FROM table_name ".
" WHERE field1 REGEXP '$search_word' ".
" OR field2 REGEXP '$search_word' ".
" OR field3 REGEXP '$search_word' ".
" OR field5 REGEXP '$search_word' ".
" ORDER BY field1 ";
$result = mysql_query($sql)
or die("Error searching: ".mysql_error());
while ($wrn = mysql_fetch_array($result) ) {
// here display the results
}
[/php]
Ronald
Oct 15 '07 #3
backups2007,

The lowtech solution is to have a form which allows the user to search the inventory, post the information to a search results page. This page tests the information from the form and then, if it's good executes a search on the database displaying any selected results.

The Form
[html]
<form id="searchForm" action="searchresults.php" method="post">
<input type="text" size="20" id ="searchText"name="searchText"/>
<input type="submit" id="SearchButton" value="Search" />
</form>
[/html]

The PHP
[php]
<?php
// test the data
if(!empty($_POST['searchText']))
{
// search the database
}
[/php]

This should give you a starting point, I do not know your data structure so you'll have to put in the SQL. But then it's a case of echoing out the results or displaying a message saying there are no matches.

Cheers
nathj
What if I put a dropdown box that may give a user an option which table to choose to search in. If for example, I have a user, product, and employee table.

Could you give any suggestions with that? Thanks in advance...
Oct 17 '07 #4
I would recommend a good full text search, doing a select on a inventory system will bog down your system fast.

http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html
Oct 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Roar | last post by:
Hi! I have got 1 access 2000 DB, one simple search form, and 3 .asp pages (one for deleting a record, one for inserting a record and one for listing searchresults). Deleting records works fine,...
1
by: Yasso Picasso | last post by:
Greetings, I have to admit that I'm still a beginner in the database field, but I'm actively studying, and this is why I will be utterly grateful for the proper, accurate, and wise guidance to...
1
by: David Gibson | last post by:
Hi, I wonder if anyone can help with the following on a fee paying basis for the the design or development of some type of script or utility or piece of code to do the following work. I wish...
5
by: William Wisnieski | last post by:
Hello Everyone, I'm really stuck on how to design this application, so I thought I'd see if anyone had any general ideas on how to proceed. I'd say I'm an intermediate level Access developer. ...
7
by: Dan | last post by:
Hi. I'm having a problem with searching a databse entry. I'm new to dotnet and still trying to figure some things out. In order to locate a row in an access databse file .mdb, i am using this...
3
by: Frustrated Developer via DotNetMonster.com | last post by:
I have posted a couple times on here already and found the user community to be very helpful. I took on a project before I realized how difficult a time I'm having working with a database....
4
by: visionstate | last post by:
Hi there, I'm fairly new to access and the way it works and I have been building a relatively simple database. It is basically a database where staff members can search for what training they (or...
3
by: Chris H | last post by:
Ok in the following code I am trying to have my keywards meta tag auto insert the top 10 titles from most recently added database entries, right now the while loop is only setting the $keyword...
5
by: Martien van Wanrooij | last post by:
I have been using phpdig in some websites but now I stored a lot of larger texts into a mysql database. In the phpdig search engine, when you entered a search word, the page where the search word...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.