Hi,
I'm trying to export the result of 2 different mysqlquery from 2 different database on the same server with the same user and password.
I'm sure i'm pretty close but it does not output any result. Here my sample code:
<?php include("/home/decpromo/public_html/admin/login.php"); ?>
<?php
//
// establish database connection
//
$handle_db1 = mysql_connect("localhost","user","pw", "true");
$handle_db2 = mysql_connect("localhost","user","pw", "true");
mysql_select_db( "db1", $handle_db1 ) or die( mysql_error( $handle_db1 ) );
mysql_select_db( "db2", $handle_db2 ) or die( mysql_error( $handle_db1 ) );
$resQuery = 'SELECT column1,column2,column3,column,FROM table1, table2 WHERE table1.column1 = othertable.other clumn'; $which = $handle_db1; mysql_query($resQuery,$which);
$resQuery = 'SELECT column1,column2,column3,column,FROM table1, table2 WHERE table1.column1 = othertable.other clumn'; $which = $handle_db1; mysql_query($resQuery,$which);$which = $handle_db2; mysql_query($resQuery,$which);
// Liste les données de la table
// -------------------------------------------
header("Content-Type: application/csv-tab-delimited-table");
header("Content-disposition: filename=table.csv");
if (mysql_num_rows($resQuery) != 0) {
// titre des colonnes
$fields = mysql_num_fields($resQuery);
$i = 0;
while ($i < $fields) {
echo mysql_field_name($resQuery, $i).";";
$i++;
}
echo "\n";
// données de la table
while ($arrSelect = mysql_fetch_array($resQuery, MYSQL_ASSOC)) {
foreach($arrSelect as $elem) {
echo "$elem;";
}
echo "\n";
}
}
?>
Any clue
Thanks