Liste deroulante avec PEAR
RésoluLiLou LiLa Messages postés 330 Statut Membre -
j'aimerai savvoir comment faire pour creer une liste deroulante en utilisant pear
en php j'ai :
echo "<select name='ref' size=1>";
while ($lig2=mysql_fetch_row($res2))
{
echo'<option value='.$lig2[0].'>'.$lig2[0].'</option>';
}
echo "</select>";
?>
c'ets pareil en pear??
MERCI D'AVANCE
Configuration: Linux Firefox 2.0.0.11
7 réponses
La problématique centrale est de générer une liste déroulante en PHP en utilisant PEAR, et de savoir si la même approche que le code HTML/PHP standard s'applique. Pour PEAR, la liste déroulante se construit comme en PHP classique, mais il faut s'assurer que les extensions et la librairie DB sont correctement chargées et que la requête renvoie des résultats. Des erreurs fréquentes comme 'Call to undefined function: fetchRow' ou des résultats nuls sont discutées, avec des conseils sur le chargement correct de DB.php, l’utilisation de fetchRow et DB_FETCHMODE_ASSOC. Enfin, des échanges notent que l'affichage peut rester vide si la requête ne retourne aucun résultat, et que certains proposent des alternatives pour éviter l'affichage en l'absence de données.
-
Salut!
Te revoila ^^
Comme je te l'ai deja dit PEAR est un framework, et ça ne va pas changer la façon de faire une liste déroulante. Donc ta liste déroulante est très bien comme elle est.
Par contre je me demandais l'interet de mettre tes select en echo?!?
echo "<select name='ref' size=1>";
echo "</select>";-
coucou :)
t'es attiré par mes soucis de codage dis donc :p
je sais pas pour les select, comme ça ou autrement c'est casi pareil ^^
l'interet c'est pour si ya pas de resultat rien afficher mais bon je le fais pas ça :p
donc je laisse ma liste comme ça :)
jai un soucis, un message d'erreur ; ça viendrait de la connexion mais je sais pas quoi faire pour arranger ça
Fatal error: Call to undefined function: assertextension() in /usr/share/pear/DB/mssql.php on line 79
-
-
Bah t'appelles une fonction qu'il ne trouve pas.
Et en effet, elle n'est pas dans /usr/share/pear/DB/mssql.php-
quel fonction?
mon code c'est :<?php error_reporting(E_ALL); include ("connexion.php"); ?>
et connexion.php c'est :
<?php require_once('DB.php'); $dbType="mysql"; $host="*******"; $account="***"; $pass="***"; $dbName="cartouche"; $dsn=$dbType."://".$account.":".$pass."@".$host."/".$dbName; $db = DB::connect($dsn); if (DB::isError($db)){ echo"ERREUR :".$db->getMessage(); } ?>
-
-
Regarde dans DB.php si il y a la fonction assertextension() !
-
Le voila le probleme!!
Dans mon db.php je l'ai cette fonction, et visiblement il te la manque...
Je te la passe t'as qu'a l'insérer...
function assertExtension($name)
{
if (!extension_loaded($name)) {
$dlext = OS_WINDOWS ? '.dll' : '.so';
$dlprefix = OS_WINDOWS ? 'php_' : '';
@dl($dlprefix . $name . $dlext);
return extension_loaded($name);
}
return true;
}
Il faut que tu l'inseres dans la classe DB-
moi dans class DB j'ai :
class DB { function &factory($type, $options = false) { if (!is_array($options)) { $options = array('persistent' => $options); } if (isset($options['debug']) && $options['debug'] >= 2) { // expose php errors with sufficient debug level include_once "DB/{$type}.php"; } else { @include_once "DB/{$type}.php"; } $classname = "DB_${type}"; if (!class_exists($classname)) { $tmp = PEAR::raiseError(null, DB_ERROR_NOT_FOUND, null, null, "Unable to include the DB/{$type}.php" . " file for '$dsn'", 'DB_Error', true); return $tmp; } @$obj = new $classname; foreach ($options as $option => $value) { $test = $obj->setOption($option, $value); if (DB::isError($test)) { return $test; } } return $obj; }
je le rajoute après ton truc? -
-
-
-
-
-
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question -
Je t'aurai bien copié la mienne, mais elle fait plus de 500 lignes...
Bah oui rajoute le apres! -
L'erreur n'est pas sur la ligne echo mais sur la ligne du dessus, tu appelles la fonction fetchrow() qui est inconnu!
-
tu veux vraiment le savoir :o .... c'est parti :
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46 Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
tout ca :) (ligne 46 = echo blabla)
c'est un peu repititif mais c'est mes messages d'erreurs -
-
Re,
Tes erreurs sont normales, tu as cette ligne de code :while($result=$rsc->fetchRow(DB_FETCHMODE_ASSOC)){ }
Or, que peux tu remarquer dans ton test ? Tu fais une AFFECTATION et non un test, ce qui est donc toujours TRUE, donc ta boucle est toujours vérifiée !
Or, comme dis plus haut, la fonction fetchRow n'existe pas, conclusion la valeur 'null' est attribuée à ta variable $result, du coup lorsque tu tente d'accèder à ce qu'il y a dedans (cf $result[0], [1], [2]), tu as l'erreur comme quoi l'offset 0, 1, 2 sont inconnus (puisque ta variable est nulle)
Conclusion, ajoute un test dans ta boucle comme ceci :while( ($result=$rsc->fetchRow(DB_FETCHMODE_ASSOC)) != null ){ }
Et puis bien sur il faut modifier la fonction appelée si elle n'existe pas (fetchRow)
-
-
-
-
oui yavait ça et autre chose
c'est bon ça marche :)
<?//liste deroulante pour selection par reference $rsc2=$db->query("SELECT Distinct IdReference FROM sorties;"); if(DB::isError($rsc2)) die($rsc2->getMessage()); echo "Selection par reference de cartouche"; echo "<form action=\"choixref.php\" method=\"post\">"; echo "<select name=\"ref\" size=1>"; while ($row2=$rsc2->fetchRow()) { echo"<option value='".$row2[0]."'>".$row2[0]."</option>"; } echo "</select>"; echo "<input type=\"submit\" name=\"valideref\" value=\"Rechercher\">"; echo "</form>"; ?>
il ne prenait pas ma requete jai un soucis avec la table , aucune requete ne marche dessus
mais pour ça c'est bon ;)
merci beaucoup