1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
<?php
session_start();
// Inclusion des paramètres de connexion à votre base de données
require_once('Connections/connex1.php');
mysql_select_db($database_connex1,$connex1);
$insertSQL11 = sprintf("select currency,amount from currency where currency = '".$_SESSION["currency"]."'");
$query11 = mysql_query($insertSQL11,$connex1) or die(mysql_error()) ;
$row11 = mysql_fetch_row($query11);
if ($row11[0] =='Chinese Yuan CN'){
$curr =$row11[1] ;
$currency ='Yuan';
$real_curr ='Chinese Yuan CN';
}
else{
$curr =1 ;
$currency ='US $';
$real_curr ='US $';
}
// Titre des colonnes de votre fichier .CSV ou .XLS
$fichier = "Destination; Calling rate(".$currency."); ";
$fichier .= "\n";
// Requête SQL
require_once('Connections/connex4.php');
mysql_select_db($database_connex4,$connex4);
$sql = "select destination,rateinitial,id,dialprefix from cc_ratecard";
$req = mysql_query($sql,$connex4);
// Enregistrement des résultats ligne par ligne
while($row = mysql_fetch_object($req))
{
$call_rate1 =round(($row->rateinitial*$curr),4) ;
$call_rate = number_format($call_rate1, 4, '.', '');
$buyrate1 =round(($row->buyrate*$curr),4) ;
$buyrate = number_format($buyrate1, 4, '.', '');
$fichier .= "".$row->dialprefix.";".$row->destination.";".$call_rate."\n";
}
// Déclaration du type de contenu
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=rates.csv"); // Remplacer .csv par .xls pour exporter en .XLS
print $fichier;
exit;
?> |
Partager