srinivas6203 Posted April 21, 2008 Share Posted April 21, 2008 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 https://forums.phpfreaks.com/topic/102090-mysql-search/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.