Selecting only one day from week

Thread Solved

Join Date: Dec 2008
Posts: 10
Reputation: ripper1510 is an unknown quantity at this point 
Solved Threads: 0
ripper1510 ripper1510 is offline Offline
Newbie Poster

Selecting only one day from week

 
0
  #1
Dec 17th, 2008
I am really stuck with any idea on how to do this. It is really confusing. Is there any way in PHP that i can select only one day of the week. My scenario is that people are only allowed to make reservations on a Friday. Is there any way i can pull only Friday and use it with date() or strftime()? And use it in drop down boxes(menus)?

Any help will be appreciated.
Last edited by ripper1510; Dec 17th, 2008 at 6:37 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 323
Reputation: compdoc is an unknown quantity at this point 
Solved Threads: 21
compdoc's Avatar
compdoc compdoc is offline Offline
Posting Whiz

Re: Selecting only one day from week

 
0
  #2
Dec 17th, 2008
you might want to use an if statement to compare whatever day today is to the string Friday.

for example
  1. $friday = 'Friday';
  2. if(date(l) == $friday){
  3. //drop down boxes, menus or other code here
  4. }
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 309
Reputation: Aamit has a little shameless behaviour in the past 
Solved Threads: 13
Aamit Aamit is offline Offline
Posting Whiz

Re: Selecting only one day from week

 
0
  #3
Dec 18th, 2008
You have got the date of friday's date
like
  1. $pf_time1 = strtotime("next Friday");
  2. $pf_date1 = date("Y-m-d h:i:s", $pf_time1);
  3. //$pf_date1 = date("Y-m-d 00:00:00",$pf_time1); use if use don't want time only date display
  4. echo"<br/>".$pf_date1;

store your date in database check_date column or depends on your logic check
  1. $sql=mysql_query("select check_date from table where check_date=curdate() ")or die("Error: ".mysql_error());
  2.  
  3. or
  4.  
  5. $sql=mysql_query("select check_date from table where check_date=now() ")or die("Error: ".mysql_error());
  6.  
  7. $no=mysql_num_rows($sql);
  8. if($no==1)
  9. {
  10. //do what ever you want
  11. //use it in drop down boxes(menus)
  12. }

I think it solves your problem
Last edited by Aamit; Dec 18th, 2008 at 4:22 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 10
Reputation: ripper1510 is an unknown quantity at this point 
Solved Threads: 0
ripper1510 ripper1510 is offline Offline
Newbie Poster

Both amzing

 
0
  #4
Dec 18th, 2008
These are both very good ideas but i just realised what i said. Instead of making only on friday i meant making only for friday. So the client can only make appointments for friday. i.e mon-thurs and sat-sun are not an option. So when they go on the form and select an appointment time it will be put in the database as eg 19 december 2008 12:15(which is a friday) or if they would like to book for next week friday they would select 26 december 2008 16:00 which is also a friday.
I think in short i need drop downs that only show fridays for selection
Last edited by ripper1510; Dec 18th, 2008 at 5:08 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 10
Reputation: ripper1510 is an unknown quantity at this point 
Solved Threads: 0
ripper1510 ripper1510 is offline Offline
Newbie Poster

Re: Selecting only one day from week

 
0
  #5
Dec 18th, 2008
I have found the solution. Just thought i would let you know what it was. PHP.net helped. Daniweb is amazing though.

  1. <?php
  2. print "<select name=\"Start\" size=\"1\">";
  3. print "<option value=\"Select Week\" selected>Select Week</option>";
  4. for($i=0; $i<=52; $i++){
  5. $num = date("d M Y", strtotime('next friday +'.$i.' week'));
  6. print"<option value=\"{$num}\">{$num}</option> \n";
  7. }
  8. print "</select>";
  9. ?>
Last edited by ripper1510; Dec 18th, 2008 at 4:36 pm.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 918 | Replies: 4
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC