techker Posted November 14, 2011 Share Posted November 14, 2011 hey guys i have this query up to know that works like i need..but i would like to add an if clause to trigger a notification if the student has more then 2 detentions with the same teacher?? k i got this going shows me the count and the student ///search student teacher repeat fr $fileSQL="SELECT COUNT(*), `Etudiant`, `Prof` FROM Rapport_R\n" . "GROUP BY `Etudiant`, `Prof`\n" . "HAVING COUNT(*)>1"; $fileLIST=mysql_query($fileSQL); ///french\\ <? while ($row = mysql_fetch_array($fileLIST)) { ?> <? echo $row['Etudiant'] ?> a <? echo $row['COUNT(*)'] ?> retenues Avec le Professeur <? echo $row['Prof'] ?> </br> <? } ?> the DB has ID-Etudiant-Prof-Day-Notes Quote Link to comment Share on other sites More sharing options...
asmith Posted November 14, 2011 Share Posted November 14, 2011 $fileSQL="SELECT COUNT(*), `Etudiant`, `Prof`, IF(COUNT(Etudiant) > 2, 'yes', 'no') AS moreThanTwo FROM Rapport_R\n" . "GROUP BY `Etudiant`, `Prof`\n" . "HAVING COUNT(*)>1"; Quote Link to comment Share on other sites More sharing options...
techker Posted November 14, 2011 Author Share Posted November 14, 2011 hmm cool.what would the echo look like? echo ['COUNT(Etudiant') Quote Link to comment Share on other sites More sharing options...
asmith Posted November 14, 2011 Share Posted November 14, 2011 if ($row['moreThanTwo'] == 'yes') // Do stuff Quote Link to comment Share on other sites More sharing options...
techker Posted November 14, 2011 Author Share Posted November 14, 2011 ya but it has to be student with teacher more than two no? cause the teacher can be repeated with other students or even that student can have a detention with other teachers.. Quote Link to comment Share on other sites More sharing options...
techker Posted November 14, 2011 Author Share Posted November 14, 2011 what about something like this if($fileLIST) { $row = mysql_fetch_array($fileLIST); $ret["Etudiant"] == >2 $row["Prof"]; } echo $row['Etudiant'] ; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.