467,161 Members | 989 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,161 developers. It's quick & easy.

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
  • viewed: 6176
Share:
3 Replies
ronverdonk
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
mmarif4u
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
Did you ever get the complete answer?
Oct 18 '06 #4

Post your reply

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

Similar topics

5 posts views Thread by elyob | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.