thedepotnetwork Posted March 8, 2010 Share Posted March 8, 2010 I am setting up a site-wide back end app to show stats from multiple sites (over 50...) I have all the database params setup in a table on the localhost site. I am connecting to them just fine, but am unable to access the data on those site, instead, it gets the local site's data... Any help? How do I refer to the outside database's tables and get data from them? while maintaining the local database connection? while($iCounter < $get_number_states) { // GET FIRST SITE PARAMS $getSQL = "SELECT * FROM states WHERE id = $current_state"; // DATABASE PARAMS $db->query($getSQL); //stepping through the 50+ states on local site's table $next_record = $db->next_record(); // GET THE FIRST STATE's DB info i.e. AlabamaWeddingLink.com state = AL id = 1 $flddb_user = $db->f("db_user"); $flddb_pass = $db->f("db_pass"); $flddb_name = $db->f("db_name"); $flddb_server = $db->f("db_server"); $fldstate_name = $db->f("state"); if($flddb_user == '') { // NOT ALL STATES are up yet... so skip those who are not up yet, only display stats for states that are up currently 33 // echo "<br/>*****************DID NOTHING FOR $current_state ***************************<br/>"; } else { // show stats for all states that are currently up //create new connection to outside site $ndb = mysql_connect($flddb_server,$flddb_user,$flddb_pass,true); mysql_select_db("$flddb_name",$ndb); echo $fldstate_name. " | "; $get_free_vendors = get_db_value("SELECT COUNT(*) FROM vendors WHERE member_type = 1", $ndb); echo $get_free_vendors." <--FREE | "; $get_paid_vendors = get_db_value("SELECT COUNT(*) FROM vendors WHERE member_type = 2", $ndb); echo $get_paid_vendors." <--PAID | "; $current_state_text = get_db_value("SELECT state FROM states", $ndb); echo $get_state_text."<br/>"; //set variables for templating codecharge engine $tpl->set_var("free_vendors", $get_free_vendors); $tpl->set_var("state_name", $current_state_text); $tpl->set_var("paid_vendors", $get_paid_vendors); } $iCounter++; $current_state++; $total_number_free += $get_free_vendors; $total_number_paid += $get_paid_vendors; $add_them_together = $get_free_vendors + $get_paid_vendors; $total_number_total += $add_them_together; $tpl->set_var("total_free", number_format($total_number_free)); $tpl->set_var("total_paid", number_format($total_number_paid)); $tpl->set_var("total_total", number_format($total_number_total)); $beg_tr = ''; $end_tr = ''; if ($tr_cnt == 1) { $beg_tr = '<tr>'; } if ($tr_cnt == 18 || $total_cnt == $num_rows) { $end_tr = '</tr>'; $tr_cnt = 0; } $tpl->set_var("beg_tr", $beg_tr); $tpl->set_var("end_tr", $end_tr); // ---------------------------------------------- $tpl->parse("ShowStats", true); $tr_cnt++; $total_cnt++; } Link to comment https://forums.phpfreaks.com/topic/194520-php-mysql-multiple-databases/ Share on other sites More sharing options...
thedepotnetwork Posted March 8, 2010 Author Share Posted March 8, 2010 Here is full file... system stats... [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/194520-php-mysql-multiple-databases/#findComment-1023102 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.