Jump to content

AP81

Members
  • Posts

    100
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

AP81's Achievements

Member

Member (2/5)

0

Reputation

  1. My bad, sorry I did this off the top of my head. Should be: return ($num_rowe >= 1);
  2. There's multiple ways to do it, but a good start is wrapping that code in a function. function hasSlotTime($slotTime) { $queuen = mysql_query("SELECT * FROM put_exam WHERE sess_id ='".$t_slot_time."'") or die(mysql_error()); $arrDatasa= array(); while($rowsa = mysql_fetch_array($queuen)) { $arrDatasa[]=$rowsa['course_code']. '|'; $docam = array_filter($arrDatasa); } foreach($arrDatasa as $a=> $rowsa){ $docama.=$docam[$a]; } //Store current coursecode to assisgn into currentass $currentass = $e_course_code; //Check for common student between the last assigned course and current course to be as $chkcomms = mysql_query("SELECT student.matric, student.std_name FROM student JOIN course_reg e1 ON e1.matric=student.matric JOIN course c1 ON c1.course_code=e1.course_code JOIN course_reg e2 ON e2.matric=student.matric JOIN course c2 on c2.course_code = e2.course_code WHERE c1.course_code = '".$currentass."' AND c2.course_code RLIKE '%$docama%' GROUP BY student.matric") or die(mysql_error()); // Count number of rows $num_rowe = mysql_num_rows($chkcomms); return ($num_rowe >= 1) { } Then you can do something like this: while (hasSlotTime($t_slot_time)) { $t_slot_times = $t_slot_time + 2; } Ideally, you shouldn't be doing queries in a loop, and if possible you should write some better code rather than using the array filter in the loop. I don't know the nature of your application and how to use it, but that is essentially what you'd do. So: Create function which does the query The function should return true if the result is >=1, otherwise false Loop until false Hopefully that is a push in the right direction.
  3. Have you tried just echoing out the variables to see what the actual values are? i.e. echo "tmp = $tmp <br />"; echo "month = $month <br />"; if($tmp !== $month){
  4. You're going to need to provide more information, such as the HTML and JavaScript, etc.
×
×
  • 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.