dans mysql_fetch_array(ressource, arrangement), l'argument arrangement, qui est par defaut MYSQL_NUM définit le choix des indexsheu c'est quoi ceperso je srais toi je l''enleverai je sais pas si ca peu être une cause de ton soucis :/MYSQL_ASSOC
Code : Tout sélectionner
SELECT nom, prenom FROM table
$a_result = mysql_fetch_array( , MYSQL_NUM)
$a_result = array( 0 => theNom, 1=> thePRenom)
$a_result[1] = thePrenom
Code : Tout sélectionner
SELECT nom, prenom FROM table
$a_result = mysql_fetch_array( , MYSQL_ASSOC)
$a_result = array( "nom" => theNom, "prenom"=> thePRenom)
$a_result["prenom"] = thePrenom
<html>
<head>
<title>page</title>
</head>
<body>
<table>
<tr>
<td>Mois</td>
<td>Annee</td>
</tr>
<?php
$str_requete ="SELECT mois, annee FROM table";
$o_result = mysql_query($str_requete)
while ($a_result = mysql_fetch_array($o_result, MYSQL_ASSOC)) {
echo "<tr>";
echo "<td>".$a_result["mois"]."</td>";
echo "<td>".$a_result["annee"]."</td>";
echo "</tr>";
}
?>
</table>
</body>
</html>
au début de ce code j'ai fait un menu deroulant ou l'utilisateur choisit une année et je voudrais en fonction de son choix que le tableau s'affiche juste pour cette annee
<html>
<head>
<title>page</title>
</head>
<body>
<table>
<tr>
<td>Mois</td>
<td>Annee</td>
</tr>
<?php
$annee=$_POST["menuderoulant"];
$str_requete ="SELECT mois, annee FROM table WHERE annee=".$annee;
$o_result = mysql_query($str_requete)
while ($a_result = mysql_fetch_array($o_result, MYSQL_ASSOC)) {
echo "<tr>";
echo "<td>".$a_result["mois"]."</td>";
echo "<td>".$a_result["annee"]."</td>";
echo "</tr>";
}
?>
</table>
</body>
</html>$annee=$_POST["annee"];
$str_requete ="SELECT jour, mois, annee, type, sla, total, description, action FROM sla ORDER BY annee, mois, jour HAVING annee=".$annee;
$o_result = mysql_query($str_requete);
while ($a_result = mysql_fetch_array($o_result, MYSQL_ASSOC)) {
J'ai cette erreur :
$str_requete ="SELECT jour, mois, annee, type, sla, total, description, action FROM sla WHERE annee=".$annee." ORDER BY annee, mois, jour";
Si tu utilise EasyPHP, je te conseille de faire afficher ta requete après l'avoir construite et de l'exécuter depuis phpMyAdmin, ca te donnera une erreur plus simple à comprendre