•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 422,602 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,645 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 786 | Replies: 10
![]() |
I am new in PHP. I have a form having fields from 3 different tables.. I want to search these 3 tables simultaniously for reporting the information...
1st table personal details.
2nd table services offered.
3rd table payment details.
I want to search each and every fields in these tables simultanioulsy...
Please help me...
1st table personal details.
2nd table services offered.
3rd table payment details.
I want to search each and every fields in these tables simultanioulsy...
Please help me...
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 239
•
•
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation:
Rep Power: 3
Solved Threads: 68
You can use the join function in mysql.Could you show us what fields are you trying to get in those tables?
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
http://ryantetek.wordpress.com
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 239
You can search multiple tables this way.
There are 2 input fields. Whatever the user enters in 1st input field will search table1 and it searches table2 for 2nd input field.
If this is not what you want, then you have to post your code.
Cheers,
Naveen
php Syntax (Toggle Plain Text)
<?php $conn=mysql_connect("localhost","root"); mysql_select_db("test"); if(isset($_POST['submit'])){ $value1=$_REQUEST['value1']; $value2=$_REQUEST['value2']; $query1="select * from table1 where column1 like '%$value1%'"; $result1=mysql_query($query1); while($row1=mysql_fetch_array($result1)){ // fetch the data for query 1 } $query2="select * from table2 where column1 like '%$value2%'"; $result2=mysql_query($query2); while($row2=mysql_fetch_array($result2)){ // fetch the data for query 2 } } ?> <html> <body> <form method="post" action="test.php"> <input type="text" name="value1"><br /> <input type="text" name="value2"><br /> <input type="submit" name="submit" value="submit"> </form> </body> </html>
There are 2 input fields. Whatever the user enters in 1st input field will search table1 and it searches table2 for 2nd input field.
If this is not what you want, then you have to post your code.
Cheers,
Naveen
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 239
Search 3 tables in a single query ? As ryan_vietnow said, you can use joins to join these 3 tables based on a condition and search for the desired fields.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation:
Rep Power: 3
Solved Threads: 68
Here's how'like it goes:
something like that.
php Syntax (Toggle Plain Text)
$query="Select * from table1 LEFT JOIN table2 USING(id) LEFT JOIN table3 USING(id) WHERE id='1'";
something like that.
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
http://ryantetek.wordpress.com
•
•
Join Date: Aug 2005
Location: somewhere in time
Posts: 71
Reputation:
Rep Power: 4
Solved Threads: 3
Here is a MySQL cheatsheet that includes examples of various table joins.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Searching multiple MS SQL Tables (VB.NET)
- Searching for a record in multiple tables (VB.NET)
Other Threads in the PHP Forum
- Previous Thread: E-Leave system
- Next Thread: PHP & Forms & Textarea



Linear Mode