Requête donne pas de résultat. Erreur syntax dans PHP?
bonsoir,
Je voudrais afficher, selon choix d'un menu, tout les événements d'un certain type (il y à 2). J'ai créer la page qui devrais afficher les résultats dans un tableau.
Mais il n'y à rien qui 's-affiche.
J'ai copier le sql directement dans MySql et j'obtiens bien le résultat escompté.
Quand je change dans mon script le sql par qqc de très simple, style Select * From 1 seul table, j'obtiens mon tableau.
Par contre, avec le sql un petit peu plus complexe, plus rien.
Vu que directement dans MySql j'ai un résultat, je peux quand même considerer que ce ne pas la requête en cause.
Est-ce que j'oublie qqc dans mon script?
Si qqn peux m'aider svp, je suis déjà coincé depuis plusieurs jours.
Voici le code de ma page.
Code:
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| <body>
<br>
<h1>Selection</h1>
<br>
<?php
$mysqli = new mysqli("host", "root", "password", "bdd");
if (mysqli_connect_errno()) {
printf("Echec de la connexion : %s\n", mysqli_connect_error());
}
if(isset($_GET['choix'])){
$choix = $_GET['choix'];
Switch($choix)
{
Case ($choix == 2):
$sql = "SELECT t_rendezvous.HoraireDebut, tbl_clientfournisseur.Nom, tbl_clientfournisseur.Adresse, tbl_clientfournisseur.Localité
FROM tbl_clientfournisseur INNER JOIN (t_rendezvous INNER JOIN tbl_eventsorte ON t_rendezvous.IdEvent = tbl_eventsorte.IdEvent) ON tbl_clientfournisseur.IdClient = t_rendezvous.NP
WHERE (((tbl_eventsorte.IdEvent)=2))";
break;
Case ($choix == 3):
$sql = "SELECT t_rendezvous.HoraireDebut, t_rendezvous.HoraireFin, tbl_clientfournisseur.Nom, tbl_clientfournisseur.Adresse, tbl_clientfournisseur.Localité, tbl_clientfournisseur.CodePostale,
tbl_PaysMonde.`Country French`, tbl_eventsorte.Description FROM tbl_PaysMonde INNER JOIN (tbl_clientfournisseur
INNER JOIN (t_rendezvous INNER JOIN tbl_eventsorte ON t_rendezvous.IdEvent = tbl_eventsorte.IdEvent) ON tbl_clientfournisseur.IdClient = t_rendezvous.NP) ON tbl_PaysMonde.`ID TLD` = tbl_clientfournisseur.Pays
WHERE (((tbl_eventsorte.IdEvent)=3))";
break;
}
}
$resultat = mysqli_query($mysqli, $sql) or die(mysql_error());
if($resultat != false){
$Nmax = 6; // nombre par page
$Ncur = 0; // n° de la fiche courante
$Ndeb=@$_GET["num"];
}
echo "<p>";
echo "<table border='1'>
<tr>
<th>Debut</th>
<th>Chez qui</th>
<th>Adresse</th>
<th>Sorte Event</th>
</tr>";
while(($row = mysqli_fetch_assoc($resultat))&& ($Ncur<$Nmax+$Ndeb)){
if($Ncur>=$Ndeb) {
echo "<tr>";
echo "<td>" . filter_var($row['HoraireDebut'],FILTER_SANITIZE_FULL_SPECIAL_CHARS) . "</td>";
echo "<td>" . filter_var($row['Nom'],FILTER_SANITIZE_FULL_SPECIAL_CHARS) . "</td>";
echo "<td>" . filter_var($row['Adresse'],FILTER_SANITIZE_FULL_SPECIAL_CHARS) . "</td>";
echo "<td>" . filter_var($row['Localité'],FILTER_SANITIZE_FULL_SPECIAL_CHARS) . "</td>";?>
<?php }
$Ncur++;
}
echo "</table>";
echo "<br>";
?>
<table cellpadding=3>
<tr>
<?php
if($Ndeb > 0)
{ ?> <td><form method="post" action="structure.php?page=select&choix=<?php echo $choix;?>&num=<?php echo $Ndeb-$Nmax;?>">
<input type="submit" value="Precedent" width="75px"></form></td><?php }?>
<td> <?php $Npag = ceil(mysqli_num_rows($resultat)/$Nmax);
for($i = 1;$i<=$Npag;$i++) {
if($Ndeb == ($i-1)*$Nmax) { ?>Page <?php echo $i; ?>
<?php } else { ?><a href="?page=select&choix=<?php echo $choix; ?>&num=<?php echo ($i-1)*$Nmax; ?>"> <?php echo $i; ?> </a><?php }
} ?></td>
<?php
if($row) { ?><td><form method="post" action="structure.php?page=select&choix=<?php echo $choix; ?>&num=<?php echo $Ncur; ?>">
<input type="submit" value="Prochain" width="75px"></form>
</td><?php }?>
</tr>
</table>
<?php
$sql = "";
?>
<h3><center><a href="./structure.php"><font color="#c94700">Retour</a></center><h3>
</body>
</html> |