Jump to content

Query for a Drop List don't echo out


MachineGamer

Recommended Posts

I am trying to make the query work in my php script ,that allow me to echo all speciality related to the user sing in,but it doesn't give me nothing this is my query : there's Table"affecte" tha has a link between Table"enseignat" and "groupe" and in Table "groupe" there's link to Table "speciality" this images of every table 

like you see in the script and every time I click on the list it don't give me nothing first of all I've tried this one:

 
<ul class="nostart">
            <select name="select" class="textfields" id="Speciality">
              <option id="0">-- Select Speciality --</option>
              <?php
  
                  $getallSpeciality = mysql_query("select Nom_Specialite from specialite where enseignant.Id_enseignant=''+mail+'''   and enseignant.`Id_Enseignant`=affecte.`Id_Enseignant` and affecte.`Id_Groupe`=groupe.`Id_Groupe` and specialite.`Id_Specialite`=groupe.`Id_Specialite`;");
                  while($viewallSpeciality = mysql_fetch_array($getallSpeciality)){
                  ?>
                  <option id="<?php echo $viewallSpeciality['Id_Specialite']; ?>">
                 <?php echo $viewallSpeciality['Nom_specialite'] ?></option>
                 <?php } ?>
           </select>
         </ul>

 select Nom_Specialite from specialite,enseignant,affecte,groupe where enseignant.mail_enseignant=''+mail+'''   and enseignant.`Id_Enseignant`=affecte.`Id_Enseignant` and affecte.`Id_Groupe`=groupe.`Id_Groupe` and specialite.`Id_Specialite`=groupe.`Id_Specialite`;
UPDATE evaluation SET Td='11' WHERE Matricule='1' 

www2.0zz0.com/2014/04/28/01/167085039.jpg
 www2.0zz0.com/2014/04/28/01/793102561.jpg
 www2.0zz0.com/2014/04/28/01/324938650.jpg
 i want to displaye speciality that linked to enseignant ! ,and if tried SELECT * FROM specialite it giving all the speciality ,but what I am trying to do is to echo for every enseignant "user" his speciality ,my login.php is in a separate file and this code is from my note-on.php ,I will very grateful for any help thanks in advance !

Link to comment
Share on other sites

Couple things, first your query has syntax errors.  This one for sure, there shouldn't be a ; at the end =groupe.`Id_Specialite`; and not sure what you're doing here ''+mail+''' but with all those quotes I am sure it's causing issues.  Second the option tag generally doesn't use an id, it should be using the value tag instead to hold the $viewallSpeciality['Id_Specialite'] you are putting in to it.

 

Lastly you can put or die(mysql_error()) at the end of your query to show you why it failed.  Although you should really stop using the mysql functions since they are now deprecated and will be removed in the future from php.  It would be a good time to start using PDO or mysqli instead.

Link to comment
Share on other sites

Hey ,i've tried to change what u told me ,but still not working and it giving me no error 

<ul class="nostart">
          <select name="select" class="textfields" id="Speciality">
<option id="0">-- Select Speciality --</option>
<?php
              if(isset($_SESSION['email'])){
$getallSpeciality = mysql_query("select Nom_Specialite from specialite where  enseignant.`Id_Enseignant`=affecte.`Id_Enseignant` and affecte.`Id_Groupe`=groupe.`Id_Groupe` and groupe.`Id_Specialite`=specialite.`Id_Specialite`")or die(mysql_error());
while($viewallSpeciality = mysql_fetch_array($getallSpeciality)){
?>
<option id="<?php echo $viewallSpeciality['Id_Specialite']; ?>">
<?php echo $viewallSpeciality['Nom_specialite'] ?></option>
<?php }} ?>
 </select>
        </ul>

and about the +mail+ it's for the java ,my friend have tried the query in java and it worked this the query that worked :

select Nom_Specialite from specialite,enseignant,affecte,groupe where enseignant.mail_enseignant=''+mail+'''   and enseignant.`Id_Enseignant`=affecte.`Id_Enseignant` and affecte.`Id_Groupe`=groupe.`Id_Groupe` and specialite.`Id_Specialite`=groupe.`Id_Specialite`;

but it display nothing on the list and i watched a video tutorial showing me how to make a drop list with a query ,i can't learn PDO or mysqli because i don't have time too this work is for my final project on university ,i hope that u give me a answer i will be very grateful thanks !

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.