deepson2 Posted August 10, 2009 Share Posted August 10, 2009 Hello, I am working on quiz. Each day i want to show one quiz according to the schedule(today's date). But i want to show this quiz till Monday to Friday. according to 1 days interval i am showing previous days result. But got stuck when Friday comes because i want to show Fridays result on Monday not on Saturday. so can anyone tell me how can i do that. here is my code. <? $sql ="SELECT * FROM schedule where start_date = date(now()) AND quiz_id like '%FIB%'"; $sql_result=mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($sql_result) > 0) { while($row = mysql_fetch_array($sql_result)) { $quizid=$row['quiz_id']; //echo "$quizid"; }?> <h4>Fill in the blanks</h4> <p class="desc1">Select the correct option.<br/>Score: 1 Point for the correct answer.</p> <? $query= mysql_query( "SELECT * FROM fillintheblank WHERE quizid='$quizid'"); if(mysql_num_rows($query) > 0){ while($row = mysql_fetch_assoc($query)){ ?> <form action="<?$PHP_SELF;?>" method="post"> <table style='font:12px Verdana, Arial, sans-serif; padding: 0 0 20px 0;'> <tr> <td style='padding: 20px 0 10px 0; line-height:20px;'><b>Q.</b> <?=$row['question'];?> </td> </tr><tr><td> <? $options=$row['answer']; $string = explode(",",$options); $total_count=count($string); //echo "$total_count"; ?> <? for($i=0;$i<$total_count;$i++) { ?> <input type="radio" value="<?php echo $string[$i]; ?>" name="answer"> <?php echo $string[$i];?> <br/> <?php } // End while loop.?> </td> </tr> <tr><td><br/> <input class="submit" type="submit" name="submit" value="submit"> </td></tr> </table> <input type ="hidden" value="<?php echo $row['quizid']; ?>" name="quizid"> <input type ="hidden" value="<?php echo $row['correct_answer']; ?>" name="correct_answer"> <p> </p><p> </p> </form> <?}}} // this gives me link to see the previous days result. $query= mysql_query("SELECT * FROM schedule WHERE (quiz_id like '%FIB%' AND start_date = DATE_SUB(CONCAT(CURDATE(), ' 00:00:00'), INTERVAL 1 DAY))"); if(mysql_num_rows($query) > 0) { while($row = mysql_fetch_array($query)) { $quiz_id=$row['quiz_id']; //echo "$quiz_id"; $start_date=$row['start_date']; //echo "$start_date"; } } else { } mysql_free_result($query); ?> So my question is how can i check with my query if it is Friday the n show that days quiz result on Monday? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/169571-solved-day-query/ Share on other sites More sharing options...
deepson2 Posted August 10, 2009 Author Share Posted August 10, 2009 My schedule table is like this id quiz_id start_date end_state 1 MTC01 2009-07-29 2009-07-29 2 MTC02 2009-08-09 2009-08-09 3 MTC03 2009-08-10 2009-08-10 4 CA_TF_PR_001 2009-08-09 2009-08-09 5 DM_FIB_PR_003 2009-08-10 2009-08-10 6 UD_TF_PR_003 2009-08-10 2009-08-10 Quote Link to comment https://forums.phpfreaks.com/topic/169571-solved-day-query/#findComment-894663 Share on other sites More sharing options...
fenway Posted August 10, 2009 Share Posted August 10, 2009 I'm not sure I follow. Quote Link to comment https://forums.phpfreaks.com/topic/169571-solved-day-query/#findComment-894781 Share on other sites More sharing options...
deepson2 Posted August 11, 2009 Author Share Posted August 11, 2009 Thanks for your reply fenway. I have solved my problem. $weekday = date('w'); I can check which day is today and accordingly i am not running my query when $weekday ='6' or $weekday ='0' because 6 represents Saturday and 0 represents Sunday.So i will keep both the days and using switch case i am applying my query. I hope this ll help someone who is looking out for this. Quote Link to comment https://forums.phpfreaks.com/topic/169571-solved-day-query/#findComment-895334 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.