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

How to retrieve data from mysql using drop down menu with text search field.

mmarif4u
Hi everyone,
I have a little problem in php coding.
i have mysql table guestbook:
Fields are Id,name,email,comment,datetime.
Now i want to search the database by php query using
a Dropdown menu (for example Name,Id) with a text search field.
What will be the query.
Can anyone help me with details.
thanks.
Sep 30 '06 #1
3 6531
ronverdonk
4,258 Expert 4TB
May I conclude from your question ("What will be the query?") that you already have the drop-down and the textbox? If so, the table query can be defined as something like (search items in $search1 and $search2):
Expand|Select|Wrap|Line Numbers
  1. $sql  = 'SELECT Id, Name ';
  2.         $sql .= 'FROM MyTable ';
  3.         $sql .= 'WHERE Name REGEXP "' . $search1 . '" ';
  4.         $sql .= 'AND Id REGEXP "' . $search2 . '" ';
  5.         $sql .= 'ORDER BY Id';
Ronald :cool:
Sep 30 '06 #2
May I conclude from your question ("What will be the query?") that you already have the drop-down and the textbox? If so, the table query can be defined as something like (search items in $search1 and $search2):
Expand|Select|Wrap|Line Numbers
  1. $sql  = 'SELECT Id, Name ';
  2.         $sql .= 'FROM MyTable ';
  3.         $sql .= 'WHERE Name REGEXP "' . $search1 . '" ';
  4.         $sql .= 'AND Id REGEXP "' . $search2 . '" ';
  5.         $sql .= 'ORDER BY Id';
Ronald :cool:
Thanks Ronald for reply.
i dont have the complete code in php.
Can u help me here in code.
Thanks.
Oct 2 '06 #3
rdub
1
Did you ever get the complete answer?
Oct 18 '06 #4

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

Similar topics

5
by: elyob | last post by:
I've got a list of towns in a MySQL database, which I currently pull from the database ... e.g. http://www.local-hotel.com/townsall/AU/ I now want to put a etc menu at the top, which will...
10
by: Haines Brown | last post by:
I've implemented the horizontal drop down menu discussed recently in this newsgroup, and it works nicely under Galeon and Mozilla, but not IE 5.0. Here are the problems: Under IE 5.0, the...
4
by: Yuk Cheng | last post by:
<<<start index.htm>>> <html> <head> <script> function perform(action){ } </script> </head>
3
by: Satish | last post by:
Hi, I am facing problem with, sending data frm mdi child to mdi parent. I have search Dropdown in MDI form, depend on selection, or enter string(its like IE URL functionality) and click...
0
by: tusaar | last post by:
Hi all I am in big need for a drop down menu created with php, mysql and ajax. Exactly, I need three drop down menu (Category, Subcategory and Item). The data of each drop down will come from...
2
by: Boujii | last post by:
Greetings, I have been attempting to make a drop down menu of countries. From this menu I wish to create a variable in order to INPUT into mysql database. I have no trouble making the drop down menu,...
21
by: giandeo | last post by:
Hello Experts. Is it possible to retrieve the value from a populated pull down menu from a database and then use that value to access the same database to get the related fields. Example: ...
11
by: tokcy | last post by:
Hi everyone, I am new in php and ajax, i am facing the prob while i click on element of first drop down then in second dropdown all element showl come from database. I mean i have three dropdown 1....
12
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.