| | |
Selecting only one day from week
Thread Solved |
•
•
Join Date: Dec 2008
Posts: 10
Reputation:
Solved Threads: 0
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.
Any help will be appreciated.
Last edited by ripper1510; Dec 17th, 2008 at 6:37 pm.
you might want to use an if statement to compare whatever day today is to the string Friday.
for example
for example
PHP Syntax (Toggle Plain Text)
$friday = 'Friday'; if(date(l) == $friday){ //drop down boxes, menus or other code here }
•
•
Join Date: Apr 2008
Posts: 309
Reputation:
Solved Threads: 13
You have got the date of friday's date
like
store your date in database check_date column or depends on your logic check
I think it solves your problem
like
PHP Syntax (Toggle Plain Text)
$pf_time1 = strtotime("next Friday"); $pf_date1 = date("Y-m-d h:i:s", $pf_time1); //$pf_date1 = date("Y-m-d 00:00:00",$pf_time1); use if use don't want time only date display echo"<br/>".$pf_date1;
store your date in database check_date column or depends on your logic check
PHP Syntax (Toggle Plain Text)
$sql=mysql_query("select check_date from table where check_date=curdate() ")or die("Error: ".mysql_error()); or $sql=mysql_query("select check_date from table where check_date=now() ")or die("Error: ".mysql_error()); $no=mysql_num_rows($sql); if($no==1) { //do what ever you want //use it in drop down boxes(menus) }
I think it solves your problem
Last edited by Aamit; Dec 18th, 2008 at 4:22 am.
•
•
Join Date: Dec 2008
Posts: 10
Reputation:
Solved Threads: 0
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
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.
•
•
Join Date: Dec 2008
Posts: 10
Reputation:
Solved Threads: 0
I have found the solution. Just thought i would let you know what it was. PHP.net helped. Daniweb is amazing though.
PHP Syntax (Toggle Plain Text)
<?php print "<select name=\"Start\" size=\"1\">"; print "<option value=\"Select Week\" selected>Select Week</option>"; for($i=0; $i<=52; $i++){ $num = date("d M Y", strtotime('next friday +'.$i.' week')); print"<option value=\"{$num}\">{$num}</option> \n"; } print "</select>"; ?>
Last edited by ripper1510; Dec 18th, 2008 at 4:36 pm.
![]() |
Similar Threads
- selecting records between selected dates (MS SQL)
- Head the Information Technology (Post your Resume)
- PayPal? - vs. other online escrow services (eCommerce)
- Pop-Up Calendar for ASP (ASP)
Other Threads in the PHP Forum
- Previous Thread: Change the head child tags in the body?
- Next Thread: open save dialog box error
Views: 918 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for PHP
access ajax apache array arrays beginner binary box buttons cakephp cart check checkbox class cms code cookies database date delete directory display download dropdown drupal dynamic echo email error file files form forms function functions header href htaccess html image images include insert ip java javascript joomla jquery limit link list login loop mail menu methods mlm mod_rewrite multiple mysql order output parse password paypal php problem query radio regex remote results script search security select server session soap sort sorting source sql string system table tutorial update updates upload url user validation validator variable video web website wordpress xml





