Hi Guys I need urgent help. I am trying to search multiple databases and return the results to one page. The databases have the same table and fields. I have managed to connect to two databases, but I have problems displaying the results from both databases. I am stuck with the code below and don't know where to any more... As the code is, I can search from only one database and not the second. <?php $conn = mysql_connect( 'localhost', 'xxxxx', 'xxxxxxx' ); mysql_select_db( 'xxxxxxxx', $conn ); $conn2 = mysql_connect( 'localhost', 'xxxxxxxx', 'xxxxxxx' ); mysql_select_db( 'xxxxxxxxxxx', $conn2 ); $term = $_POST['term']; { $select = mysql_query( "SELECT * FROM data WHERE ID_NUMBER like '%$term%'", $conn); $select1 = mysql_query( "SELECT * FROM data WHERE ID_NUMBER like '%$term%'", $conn2); $coloum = mysql_fetch_array($select) ?> Code (markup): Can anyone please help with the code?
You can try with one cross database query only if the user has access to both databases: Something like: SELECT * FROM db1.data WHERE ID_NUMBER like '%$term%' UNION SELECT * FROM db2.data WHERE ID_NUMBER like '%$term%' Code (markup): If you want to know where the result row came from, you can add one rudimentary field for each select.