Code: Select all
//$mf_array = Array containing database's and their connection details
//$RMquery_array = Array containining MySQL queries
$RMa = array(); //new array to be created
foreach($mf_array as $rm_array) {
$con = mysql_connect($rm_array['server'], $rm_array['user'], $rm_array['password']);
mysql_select_db($dbs, $con);
for($a = 0; $a <sizeof($mf_array); $a++) {
$RMa[$a]['db'] = $mf_array[$a]['database']; // This bit works fine, adding the correct database names to the new Array
// QUERY 1
$RMres = mysql_query($RMquery_array[0]['query1']) ;
if ( !$RMres ) { $error = mysql_error();
print "<table ><tr><th>ERROR HAS OCCURRED</th></tr>\"";
print "<tr><td>".$error."</td></tr></table>";
}
while($RMrow = mysql_fetch_assoc($RMres)) {
$instance[$rm_array['database']] = $RMrow;
$RMa[$a]['allowRun'] = $RMrow['allowRun'];
$RMa[$a]['whenSet'] = $RMrow['whenSet'];
}
// QUERY 2
$RMres2 = mysql_query($RMquery_array[0]['query2']) ;
if ( !$RMres2 ) { $error = mysql_error();
print "<table><tr><th>ERROR HAS OCCURRED</th></tr>\"";
print "<tr><td>".$error."</td></tr></table>";
}
while($RMrow2 = mysql_fetch_assoc($RMres2)) {
$instance2[$rm_array['database']] = $RMrow2;
$RMa[$a]['id'] = $RMrow2['id'];
$RMa[$a]['now_running'] = $RMrow2['now_running'];
$RMa[$a]['dt'] = $RMrow2['dt'];
}
}
mysql_close($con);
};
Array
(
[0] => Array
(
[db] => MySQL06
[allowRun] => 0
[whenSet] => 2011-01-26 09:43:00
[id] => 14
[now_running] => Processing completed
[dt] => 2011-01-24 15:54:23
)
[1] => Array
(
[db] => MySQL07
[allowRun] => 0
[whenSet] => 2011-01-26 09:43:00
[id] => 14
[now_running] => Processing completed
[dt] => 2011-01-24 15:54:23
)
)
As you can see, apart form the first element (db), everything else is the same, but the first one should look like:
[0] => Array
(
[db] => MySQL06
[allowRun] => 1
[whenSet] => 2011-01-26 09:42:00
[id] => 17
[now_running] => Processing completed
[dt] => 2011-01-24 15:50:26
)