Débutante en PHP
J'ai 2 petites questions
J'ai fait l'export de ma base de données via un bouton
Est-il possible que cet export parte plutôt Ts les jours à une certaine heure par mail ( au lieu de se rendre sur le web pour l'exporter)?
J'aurai besoin de faire différentes requêtes mais que ces différentes requêtes sois dans des pages différentes de mon Excel et non tout dans la mm page , est ce possible?
Est ce normal que ma requête avec NOW ne marche qu'en ligne et non en local?
Y'a t'il moyen d'intégrer une feuille de style pour cette page au lieu d'écrire les balises styles à même le code?
J'en n'ai une a part sauf qu'elle marche que pour le fichier index, je ne vois pas ou l'intégrée dans cette page
En vous remerciant d'avance,
Code : Tout sélectionner
<?php
$connect = mysqli_connect("localhost", "root", "root", "giraud");
if(isset($_POST["submit"]))
{
$query = "SELECT identifiant,nom,prenom,adresse,complementAdresse,ville,codePostal,mail,fixe,portable,kit,tube,aiguille,adaptateur,cartonSmall,cartonBig,etiquetteChronopost,enveloppeBulle,commentaire,dateCommande FROM exemple";
// $query = "SELECT * FROM exemple WHERE dateCommande BETWEEN DATE_ADD(DATE(NOW()),INTERVAL -7 DAY) AND DATE(NOW()) ";
$res = mysqli_query($connect, $query);
if(mysqli_num_rows($res) > 0)
{
$export = '
<h1 style="text-align:center"> recapitulatif de toutes les commandes </h1>
<table>
<tr style="border:1px solid black; height:30px">
<th>identifiant</th>
<th>nom</th>
<th>prenom</th>
<th>adresse</th>
<th>complement adresse</th>
<th>ville</th>
<th>code postal</th>
<th>mail</th>
<th>fixe</th>
<th>portable</th>
<th>nbre de kits</th>
<th>nbre de tubes</th>
<th>nbre aiguilles</th>
<th>nbre adaptateur</th>
<th>nbre petit carton</th>
<th>nbre grand carton</th>
<th>nbre etiquette chronopost</th>
<th>nbre enveloppe bulle</th>
<th>commentaire</th>
<th>date commande</th>
<th>Date d envoi</th>
</tr>
';
while($row = mysqli_fetch_array($res))
{
$export .= '
<tr style="border-right:1px solid black; margin:10px">
<td>'.$row["identifiant"].'</td>
<td>'.$row["nom"].'</td>
<td>'.$row["prenom"].'</td>
<td>'.$row["adresse"].'</td>
<td>'.$row["complementAdresse"].'</td>
<td>'.$row["ville"].'</td>
<td>'.$row["codePostal"].'</td>
<td>'.$row["mail"].'</td>
<td>'.$row["fixe"].'</td>
<td>'.$row["portable"].'</td>
<td>'.$row["kit"].'</td>
<td>'.$row["tube"].'</td>
<td>'.$row["aiguille"].'</td>
<td>'.$row["adaptateur"].'</td>
<td>'.$row["cartonSmall"].'</td>
<td>'.$row["cartonBig"].'</td>
<td>'.$row["etiquetteChronopost"].'</td>
<td>'.$row["enveloppeBulle"].'</td>
<td>'.$row["commentaire"].'</td>
<td>'.$row["dateCommande"].'</td>
<td> </td>
</tr>
';
}
$export .= '</table>';
header('Content-Type: application/xls');
header('Content-Disposition: attachment; filename=commande-ifce.xls');
echo $export;
}
}
if(isset($_POST["submit"]))
{
$query = "SELECT identifiant,nom,prenom,adresse FROM exemple";
// $query = "SELECT * FROM exemple WHERE dateCommande BETWEEN DATE_ADD(DATE(NOW()),INTERVAL -7 DAY) AND DATE(NOW()) ";
$res = mysqli_query($connect, $query);
if(mysqli_num_rows($res) > 0)
{
$exporte = '
<h1 s> divers </h1>
<table>
<tr style="border:1px solid black; height:30px">
<th>identifiant</th>
<th>nom</th>
<th>prenom</th>
<th>adresse</th>
</tr>
';
while($row = mysqli_fetch_array($res))
{
$exporte .= '
<tr style="border-right:1px solid black; margin:10px">
<td>'.$row["identifiant"].'</td>
<td>'.$row["nom"].'</td>
<td>'.$row["prenom"].'</td>
<td>'.$row["adresse"].'</td>
</tr>
';
}
$exporte .= '</table>';
header('Content-Type: application/xls');
header('Content-Disposition: attachment; filename=commandes-ifce.xls');
echo $exporte;
}
}
?>