Jump to content

mysql search


srinivas6203

Recommended Posts

Hi all

 

I want display all the records from database by entering data into multiple text fields.

I am using 5 input fields like username,source,destination,fromdate,todate.

First i want to search username and source. For that i entered username as "peter" and source as "1234". For that the code as follows

 

if(($_POST['username'])) && ($_POST['source'])) {

$sql_query=mysql_query("select * from example where username='".$_POST['username']."' and source='".$_POST['source']."'");

while($row_query=mysql_query($sql_query)) {

//print records

}

 

Now i want to search username,source,destination. For that i entered username as "peter" and source as "1234". For that the code as follows

 

if(($_POST['username'])) && ($_POST['source']) && ($_POST['destination'])) {

$sql_query=mysql_query("select * from example where username='".$_POST['username']."' and source='".$_POST['source']."' and destination='".$_POST['destination']."'");

while($row_query=mysql_query($sql_query)) {

//print records

}

 

Next source,username,from date

next todate,username,fromdate and some other fields

the code was going so long.

each time i am compare and write query for this.

This was taken so much time.

How can i search by using multiple input fields by easiest way.

I am using php and mysql

 

thanks in advance

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.