472,096 Members | 1,290 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 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 6398
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

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 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.