requete avec lisbox additionnée [trouvé] [php] - PHP - Programmation
Marsh Posté le 16-12-2002 à 14:33:21
eh bin heureusement que j'ai branché mon décodeur
si tu construit ton champ select avec une boucle comme ça :
<select ...>
<option selected>Tous</option>
// la boucle qui génère des <option value ..>abcdef</option>
</select>
si tu construit la liste à partir d'un tableau tu peux toujours ajouter un élément au début du tableau, qui correspondra à ton TOUS
Marsh Posté le 16-12-2002 à 14:41:32
j ai fait la requete elle marche
mais le pb c est que les valeurs des listbox sont contenus ds des tables
alors comment faire pour avoir "tous"
ca donne ca
$site = $_GET["site"];
$service = $_GET["service"];
$societe = $_GET["societe"];
//requete qui teste l existance du nom dans la base de donnée Mysql
mysql_connect($dbhost,$dblogin,$dbpassword);mysql_selectdb($dbname);
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and serv.nom='$service' and site.nom='$site' and soci.nom='$societe'" );
Marsh Posté le 16-12-2002 à 14:42:51
et comment compter le nbre de reponse ( count result non ?)
Marsh Posté le 16-12-2002 à 14:42:52
mais on s'en fout de la requête, tu files même pas le code qui génère la liste déroulante !
Marsh Posté le 16-12-2002 à 14:48:58
OuvrirBase();
?>
<select name="site">
<? $requete="select nom from site ORDER BY nom";
$reponse = mysql_query($requete);
while ($row = mysql_fetch_array($reponse)) { ?>
<option value="<? echo $row["nom"]; ?>"><? echo $row["nom"]; ?></option>
<? } ?>
</select>
<select name="service">
<? $requete="select nom from service ORDER BY nom";
$reponse = mysql_query($requete);
while ($row = mysql_fetch_array($reponse)) { ?>
<option value="<? echo $row["nom"]; ?>"><? echo $row["nom"]; ?></option>
<? } ?>
</select>
<select name="societe">
<? $requete="select nom from societe ORDER BY nom";
$reponse = mysql_query($requete);
while ($row = mysql_fetch_array($reponse)) { ?>
<option value="<? echo $row["nom"]; ?>"><? echo $row["nom"]; ?></option>
<? } ?>
</select>
<input type="submit" value="OK"/>
</form>
Marsh Posté le 16-12-2002 à 14:52:05
sakuraba a écrit : et comment compter le nbre de reponse ( count result non ?) |
$result_count=mysql_num_rows($sql_results);
print "$result_count";
j ai trouvé ca deja
Marsh Posté le 16-12-2002 à 14:56:48
<select name="site">
<option value="0">Tous</option>
<? $requete="select nom from site ORDER BY nom";
$reponse = mysql_query($requete);
while ($row = mysql_fetch_array($reponse)) { ?>
<option value="<? echo $row["nom"]; ?>"><? echo $row["nom"]; ?></option>
<? } ?>
</select>
qu'est ce que j'ai écris plus haut ??
Marsh Posté le 16-12-2002 à 15:25:50
j'abandonne, tu as la solution sous les yeux, je peux pas en faire plus
Marsh Posté le 16-12-2002 à 15:28:16
site = $_GET["site"];
$service = $_GET["service"];
$societe = $_GET["societe"];
//requete qui teste l existance du nom dans la base de donnée Mysql
mysql_connect($dbhost,$dblogin,$dbpassword);mysql_selectdb($dbname);
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and serv.nom='$service' and site.nom='$site' and soci.nom='$societe'" );
sur cette requete
Marsh Posté le 17-12-2002 à 09:16:06
$site = $_GET["site"];
$service = $_GET["service"];
$societe = $_GET["societe"];
mysql_connect($dbhost,$dblogin,$dbpassword);mysql_selectdb($dbname);
if ($site = 'Tous' and $service = 'Tous' and $societe = "Tous" ) {
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe order by nom" );
//compter le nbre de reponse trouvée
$result_count=mysql_num_rows($sql_results);
}
elseif ($site = 'Tous' and $service = 'Tous'{
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and soci.nom='$societe' order by nom" );
}
elseif ($site = 'Tous' and $societe = 'Tous'{
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and serv.nom='$service' order by nom" );
}
elseif ($societe = 'Tous' and $service='Tous'{
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and serv.nom='$site' order by nom" );
}
elseif ($service = 'Tous' and $societe = 'Tous'{
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and serv.nom='$site' order by nom" );
}
elseif ($service = 'Tous'{
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and serv.nom='$site' and soci.nom='$societe' and order by nom" );
}
elseif ($societe = "Tous" ){
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and serv.nom='$site' and serv.nom='$service' and order by nom " );
}
elseif ($site = "Tous" ){
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and soci.nom='$societe' and serv.nom='$service' and order by nom " );
}
else{
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and soci.nom='$societe' and serv.nom='$service' and serv.nom='$site' and order by nom " );
}
//requete qui teste l existance du nom dans la base de donnée Mysql
ca fait que la premiere condition ds tous les cas
J ai besoin d aide merci
Marsh Posté le 17-12-2002 à 10:20:09
$site = $_GET["site"];
$service = $_GET["service"];
$societe = $_GET["societe"];
mysql_connect($dbhost,$dblogin,$dbpassword);mysql_selectdb($dbname);
if ($site == "Tous" and $service == "Tous" and $societe == "Tous" ) {
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe order by nom" );
//compter le nbre de reponse trouvée
$result_count=mysql_num_rows($sql_results);
//}
}
elseif ($site =="Tous" and $service == "Tous" ){
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and soci.nom='$societe' order by nom" );
$result_count=mysql_num_rows($sql_results);
}
elseif ($site == "Tous" and $societe == "Tous" ){
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and serv.nom='$service' order by nom" );
$result_count=mysql_num_rows($sql_results);
}
elseif ($societe == "Tous" and $service == "Tous" ){
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and site.nom='$site' order by nom" );
$result_count=mysql_num_rows($sql_results);
}
elseif ($service == "Tous" ){
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and site.nom='$site' and soci.nom='$societe' order by nom" );
$result_count=mysql_num_rows($sql_results);
}
elseif ($societe == "Tous" ){
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and site.nom='$site' and serv.nom='$service' order by nom" );
$result_count=mysql_num_rows($sql_results);
}
elseif ($site == "Tous" ){
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and soci.nom='$societe' and serv.nom='$service' order by nom" );
$result_count=mysql_num_rows($sql_results);
}
else{
$sql_results=mysql_query("select util.nom as 'nom',util.prenom as 'prenom',util.fonction as 'fonction',
site.nom as 'site',serv.nom as 'service',soci.nom as 'societe',util.mail 'mail',util.telephone 'telephone'
from utilisateurs util,site,service serv,societe soci
where util.id_site = site.id_site and util.id_service = serv.id_service and
util.id_societe = soci.id_societe and soci.nom='$societe' and serv.nom='$service' and site.nom='$site' order by nom" );
$result_count=mysql_num_rows($sql_results);
}
Marsh Posté le 16-12-2002 à 14:19:48
comment afficher "toutes" dans une listbox ( select * )?
______
|______| listbox1 values possible "tous,lyon,paris,marseille"
name=liste1
______
|______| listbox2 values possible "tous,msft,rh,mandrake"
name=liste2
______
|______| listbox3 values possible "tous,compta,info"
name=liste3
comment faire pour recuperer et les ajouter
genre tous(list1)+tous(list2)+info(list3) ?
mais dans tout les sens
merci
Message édité par sakuraba le 17-12-2002 à 10:42:10