par
Meite » 29 juin 2017, 19:43
Ce script ci-dessous doit afficher les informations de la table "mon-site-site_absences" sur la page d'accueil de mon site intranet.
redonne nous ton script dans son eta t actuel, et dis nous où il ne fait pas ce que tu désire.
Code : Tout sélectionner
<?php
$aujourdhui=date("Y-n-j");
$sql = "SELECT DISTINCT nom,date_depart_saf,date_retour_saf,pays,date1,date2 FROM mon-site-site_absences WHERE actif='Y' AND ";
$sql .= "((validation <'9' AND date_depart_saf<='" . $aujourdhui . "' AND date_retour_saf>='" . $aujourdhui . "') OR ";
$sql .= " (type='2' AND date1<='" . $aujourdhui . "' AND date2>='" . $aujourdhui . "')) ORDER BY nom";
$ma_requete = mysql_query($sql);
echo mysql_error();
if ($ma_requete) {
$nbrow = mysql_num_rows($ma_requete);
$affichage_php = "<p style='padding-left:8pt; font:arial; color:blue'><b><u>Liste des absences du jour</u></b> : les dates de départ et de retour sont celles du billet d'avion ou de la demande d'absence</p><table id='rounded-corner' summary='Absences de la période'>
<thead>
<tr>
<th scope='col' class='rounded-top-left'>Nom de l'agent</th>
<th scope='col' class='rounded-pays'>Pays</th>
<th scope='col' class='rounded-depart'>Date de départ</th>
<th scope='col' class='rounded-top-right'>Date de retour</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan='3' class='rounded-foot-left'><em><a href='http://mon-site-site01/intranet/index.php?option=com_content&view=article&id=93'>Pour plus d'information, merci de consulter la page des absences</a></em></td>
<td class='rounded-foot-right'> </td>
</tr>
</tfoot>
<tbody>";
if( $nbrow > 0) {
$i=1;
while ($mon_resultat = mysql_fetch_array($ma_requete)) {
//$affichage_php .= "<b>" . $mon_resultat["nom"] . "</b> (><i>" . date("d-m-Y",strtotime($mon_resultat["date2"])) . "</i>)";
//$affichage_php .= ($i++<$nbrow?", ":"");
$affichage_php .= "<tr>";
$affichage_php .= "<td>".$mon_resultat["nom"]."</td>";
if (($mon_resultat["pays"] != 'n/a')) {
$pays = $mon_resultat["pays"];
$req = mysql_query("select pays from mon-site-site_liste_pays where code3='$pays'");
$res = @mysql_fetch_array($req);
if (isset($res["pays"])) $pays = $res["pays"];
$affichage_php .= "<td>".$pays."</td>";
$affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date_depart_saf"]))."</td>";
$affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date_retour_saf"]))."</td>";
}else {
$pays = "En congés";
$affichage_php .= "<td>".$pays."</td>";
$affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date1"]))."</td>";
$affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date2"]))."</td>";
}
$affichage_php .= "</tr>";
}
}
else {
//$affichage_php .= "<div class='texte' style='padding-left:8pt; font:arial; color:blue'>>> <u>Absence(s) du jour:</u> ";
$affichage_php .="<i>aucune...</i>";
//$affichage_php .= "</div><br>";
}
$affichage_php .= "</tbody></table>";
}
$aujourdhui=date("Y-n-j");
$sql = "SELECT DISTINCT nom,date1,date2,date_depart_saf,date_retour_saf,pays FROM mon-site-site_absences WHERE actif='Y' AND ";
$sql .= "((validation = '1' AND type='1') OR (validation = '0' AND type='2')) AND date1>'" . $aujourdhui . "' OR date_depart_saf>'" . $aujourdhui . "' ORDER BY nom";
$ma_requete = mysql_query($sql);
echo mysql_error();
if ($ma_requete) {
$nbrow=mysql_num_rows($ma_requete);
$affichage_php .= "<p></p><p style='padding-left:8pt; font:arial; color:blue'><b><u>Liste des absences à venir</u></b> : les demandes ci-dessous ont été autorisées par la Direction Générale</p><table id='rounded-corner' summary='Absences de la période'>
<thead>
<tr>
<th scope='col' class='rounded-top-left'>Nom de l'agent</th>
<th scope='col' class='rounded-pays'>Pays</th>
<th scope='col' class='rounded-depart'>Départ probable</th>
<th scope='col' class='rounded-top-right'>Retour probable</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan='3' class='rounded-foot-left'><em><a href='http://mon-site-site01/intranet/index.php?option=com_content&view=article&id=93'>Pour plus d'information, merci de consulter la page des absences</a></em></td>
<td class='rounded-foot-right'> </td>
</tr>
</tfoot>
<tbody>";
if( $nbrow > 0) {
$i=1;
while ($mon_resultat = mysql_fetch_array($ma_requete)) {
//$affichage_php .= "<b>" . $mon_resultat["nom"] . "</b> (><i>" . date("d-m-Y",strtotime($mon_resultat["date2"])) . "</i>)";
//$affichage_php .= ($i++<$nbrow?", ":"");
$pays = $mon_resultat["pays"];
$req = mysql_query("select pays from mon-site-site_liste_pays where code3='$pays'");
//echo var_dump($pays)." ".var_dump($req)."<br />";
$res = mysql_fetch_array($req);
if (isset($res["pays"])) $pays = $res["pays"];
else $pays = "En congés";
$affichage_php .= "<tr>";
$affichage_php .= "<td>".$mon_resultat["nom"]."</td>";
$affichage_php .= "<td>".$pays."</td>";
if ($mon_resultat["date_depart_saf"] != '0000-00-00') $affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date_depart_saf"]))."</td>";
else $affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date1"]))."</td>";
if ($mon_resultat["date_retour_saf"] != '0000-00-00') $affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date_retour_saf"]))."</td>";
else $affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date2"]))."</td>";
$affichage_php .= "</tr>";
}
}
else {
//$affichage_php .= "<div class='texte' style='padding-left:8pt; font:arial; color:blue'>>> <u>Absence(s) du jour:</u> ";
$affichage_php .="<i>aucune...</i>";
//$affichage_php .= "</div><br>";
}
$affichage_php .= "</tbody></table>";
}
echo $affichage_php;
?>
PS le reste de mes remarques restent valables, as tu vérifier ta requète dans phpmyadmin ?
Code : Tout sélectionner
Erreur
Voici ce que ça m'affiche quand je fais le test dans SQL -> PHPMYADMIN -> Exécuter. Merci de m'éclairer.
Il semble qu'il y ait une erreur dans votre requête SQL. Le message ci-bas peut vous aider à en trouver la cause.
ERROR: Ponctuation invalide @ 1
STR: <?
SQL: <?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");
requête SQL:
<?php $aujourdhui=date("Y-n-j");
MySQL a répondu:Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<?php
$aujourdhui=date("Y-n-j")' at line 1
Ce script ci-dessous doit afficher les informations de la table "mon-site-site_absences" sur la page d'accueil de mon site intranet.
[quote]redonne nous ton script dans son eta t actuel, et dis nous où il ne fait pas ce que tu désire.[/quote]
[code]<?php
$aujourdhui=date("Y-n-j");
$sql = "SELECT DISTINCT nom,date_depart_saf,date_retour_saf,pays,date1,date2 FROM mon-site-site_absences WHERE actif='Y' AND ";
$sql .= "((validation <'9' AND date_depart_saf<='" . $aujourdhui . "' AND date_retour_saf>='" . $aujourdhui . "') OR ";
$sql .= " (type='2' AND date1<='" . $aujourdhui . "' AND date2>='" . $aujourdhui . "')) ORDER BY nom";
$ma_requete = mysql_query($sql);
echo mysql_error();
if ($ma_requete) {
$nbrow = mysql_num_rows($ma_requete);
$affichage_php = "<p style='padding-left:8pt; font:arial; color:blue'><b><u>Liste des absences du jour</u></b> : les dates de départ et de retour sont celles du billet d'avion ou de la demande d'absence</p><table id='rounded-corner' summary='Absences de la période'>
<thead>
<tr>
<th scope='col' class='rounded-top-left'>Nom de l'agent</th>
<th scope='col' class='rounded-pays'>Pays</th>
<th scope='col' class='rounded-depart'>Date de départ</th>
<th scope='col' class='rounded-top-right'>Date de retour</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan='3' class='rounded-foot-left'><em><a href='http://mon-site-site01/intranet/index.php?option=com_content&view=article&id=93'>Pour plus d'information, merci de consulter la page des absences</a></em></td>
<td class='rounded-foot-right'> </td>
</tr>
</tfoot>
<tbody>";
if( $nbrow > 0) {
$i=1;
while ($mon_resultat = mysql_fetch_array($ma_requete)) {
//$affichage_php .= "<b>" . $mon_resultat["nom"] . "</b> (><i>" . date("d-m-Y",strtotime($mon_resultat["date2"])) . "</i>)";
//$affichage_php .= ($i++<$nbrow?", ":"");
$affichage_php .= "<tr>";
$affichage_php .= "<td>".$mon_resultat["nom"]."</td>";
if (($mon_resultat["pays"] != 'n/a')) {
$pays = $mon_resultat["pays"];
$req = mysql_query("select pays from mon-site-site_liste_pays where code3='$pays'");
$res = @mysql_fetch_array($req);
if (isset($res["pays"])) $pays = $res["pays"];
$affichage_php .= "<td>".$pays."</td>";
$affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date_depart_saf"]))."</td>";
$affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date_retour_saf"]))."</td>";
}else {
$pays = "En congés";
$affichage_php .= "<td>".$pays."</td>";
$affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date1"]))."</td>";
$affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date2"]))."</td>";
}
$affichage_php .= "</tr>";
}
}
else {
//$affichage_php .= "<div class='texte' style='padding-left:8pt; font:arial; color:blue'>>> <u>Absence(s) du jour:</u> ";
$affichage_php .="<i>aucune...</i>";
//$affichage_php .= "</div><br>";
}
$affichage_php .= "</tbody></table>";
}
$aujourdhui=date("Y-n-j");
$sql = "SELECT DISTINCT nom,date1,date2,date_depart_saf,date_retour_saf,pays FROM mon-site-site_absences WHERE actif='Y' AND ";
$sql .= "((validation = '1' AND type='1') OR (validation = '0' AND type='2')) AND date1>'" . $aujourdhui . "' OR date_depart_saf>'" . $aujourdhui . "' ORDER BY nom";
$ma_requete = mysql_query($sql);
echo mysql_error();
if ($ma_requete) {
$nbrow=mysql_num_rows($ma_requete);
$affichage_php .= "<p></p><p style='padding-left:8pt; font:arial; color:blue'><b><u>Liste des absences à venir</u></b> : les demandes ci-dessous ont été autorisées par la Direction Générale</p><table id='rounded-corner' summary='Absences de la période'>
<thead>
<tr>
<th scope='col' class='rounded-top-left'>Nom de l'agent</th>
<th scope='col' class='rounded-pays'>Pays</th>
<th scope='col' class='rounded-depart'>Départ probable</th>
<th scope='col' class='rounded-top-right'>Retour probable</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan='3' class='rounded-foot-left'><em><a href='http://mon-site-site01/intranet/index.php?option=com_content&view=article&id=93'>Pour plus d'information, merci de consulter la page des absences</a></em></td>
<td class='rounded-foot-right'> </td>
</tr>
</tfoot>
<tbody>";
if( $nbrow > 0) {
$i=1;
while ($mon_resultat = mysql_fetch_array($ma_requete)) {
//$affichage_php .= "<b>" . $mon_resultat["nom"] . "</b> (><i>" . date("d-m-Y",strtotime($mon_resultat["date2"])) . "</i>)";
//$affichage_php .= ($i++<$nbrow?", ":"");
$pays = $mon_resultat["pays"];
$req = mysql_query("select pays from mon-site-site_liste_pays where code3='$pays'");
//echo var_dump($pays)." ".var_dump($req)."<br />";
$res = mysql_fetch_array($req);
if (isset($res["pays"])) $pays = $res["pays"];
else $pays = "En congés";
$affichage_php .= "<tr>";
$affichage_php .= "<td>".$mon_resultat["nom"]."</td>";
$affichage_php .= "<td>".$pays."</td>";
if ($mon_resultat["date_depart_saf"] != '0000-00-00') $affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date_depart_saf"]))."</td>";
else $affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date1"]))."</td>";
if ($mon_resultat["date_retour_saf"] != '0000-00-00') $affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date_retour_saf"]))."</td>";
else $affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date2"]))."</td>";
$affichage_php .= "</tr>";
}
}
else {
//$affichage_php .= "<div class='texte' style='padding-left:8pt; font:arial; color:blue'>>> <u>Absence(s) du jour:</u> ";
$affichage_php .="<i>aucune...</i>";
//$affichage_php .= "</div><br>";
}
$affichage_php .= "</tbody></table>";
}
echo $affichage_php;
?>[/code]
[quote]PS le reste de mes remarques restent valables, as tu vérifier ta requète dans phpmyadmin ?[/quote]
[code]Erreur
Voici ce que ça m'affiche quand je fais le test dans SQL -> PHPMYADMIN -> Exécuter. Merci de m'éclairer.
Il semble qu'il y ait une erreur dans votre requête SQL. Le message ci-bas peut vous aider à en trouver la cause.
ERROR: Ponctuation invalide @ 1
STR: <?
SQL: <?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");<?php
$aujourdhui=date("Y-n-j");
requête SQL:
<?php $aujourdhui=date("Y-n-j");
MySQL a répondu:Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<?php
$aujourdhui=date("Y-n-j")' at line 1 [/code]