|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
General - Trying to display data from multiple dbs.
PHP Code:
I have this so far. My sql statement pulls the data that I want using it in phpMyadmin. how do I get it to display onto the page? |
|
#2
|
|||
|
|||
|
Quote:
Okay, you have two databases here that I can see; ' places ' and ' list '. What I suggest you do is build two php connection classes for these. Create a $variable for each of the two mysql_connection statements. Call them something like $connone and $conntwo Once you have created these two forms, you can then use the require ( ) to call them. Here is what that would look like on the same page of code where you put your query statement. require_once (' $connone ' ) ; require_once (' $conntwo ' ) ; They will call and process. If you don't put the ' _once ' on the end of the functions, you will have them looping over and over everytime the page refreshes to process data and they will read as errors. Here is what the basic connection code looks like: <?php $host = ' localhost '; $username = ' your database username goes here '; $password = ' your database password goes here '; $database = ' your database name goes here '; $connone = 'mysql_connect('localhost', '$username', '$password'); if (!$connone) { die('Could not connect: ' . mysql_error()); } mysql_close($link); ?> Once you've done this, repeat the process with your second database connection and then you will be able to call them by their respective $variables as require () or include () function values. REMEMBER: it's critical that you use ' _once ' after whichever you use, to prevent parsing issues. With that, you have multiple connections for the purpose of your multiple databazse query. Many say that it can't be done but I use this technique all of the time for many projects. Then, all you have to do is add the displayed results however you want them down the page. Hope this helps. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > General - Trying to display data from multiple dbs. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|