473,585 Members | 2,529 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

mmarif4u
23 New Member
Hi everyone,
I have a little problem in php coding.
i have mysql table guestbook:
Fields are Id,name,email,c omment,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 6541
ronverdonk
4,258 Recognized Expert Specialist
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
mmarif4u
23 New Member
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 New Member
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
8193
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 click to the start of the towns with that letter using index.html#A .... I am guessing that the best way would be to simply compare the first letter of...
10
3458
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 there is no drop down menu functionality at all. I wanted to implement an alternative stylesheet for IE, but my link to it is apparently broken. What...
4
5761
by: Yuk Cheng | last post by:
<<<start index.htm>>> <html> <head> <script> function perform(action){ } </script> </head>
3
4441
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 search button, i am displaying Details form with all the details. Their i have Delete button. When we click on delete button, we have to delete the...
0
7354
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 Mysql. Anybody can help me please.. I will be very much thankfull. Please help me and give me a proper solution for that ASAP. Thanks Tushar
2
5246
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, but I am unable to store a variable for it. Here is a rough copy of what I am making: <html> <head> <title>Add New MySQL User</title> ...
21
2885
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: Database name: sp Table: importer Field names: imp_code, imp_name, imp_address, imp_tel
11
4621
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. category which comes from database 2. brand which comes from databse according to content of first dropdown . and 3. price which is static. when i...
12
77965
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 give me some idea where I am going wrong ?? I just want to retrieve data from my emp_mstr table and display it using my JSP file... The table...
0
7836
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8212
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6606
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2343
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.