Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6566365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:12:30+00:00 2026-05-25T14:12:30+00:00

How do you create a select with the option of 2 days ahead from

  • 0

How do you create a select with the option of 2 days ahead from today picked as the default option (i.e. a 48 hour window) in PHP? This is the code I’m using so far but it doesn’t work unfortunately!

<?php
$weekday = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
$days = range (1, 31);
$currentDay = date('F');
echo "<select name='weekday'>";
foreach ($days as $value) {
  $default = ($value == $currentDay)?'selected="selected"':'';
  echo '<option '.$default.' value="'.$value.'">'.$value."</option>\n";
}
echo '</select> &nbsp; ';
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:12:31+00:00Added an answer on May 25, 2026 at 2:12 pm

    I’m confused as to what your code does.

    As far as I can tell $weekday is not used after being instantiated, and you are setting $currentDay to the text representation of the current month (e.g. September).

    But if you want to get the day of month of the day 48 hours from now:

    $two_days_ahead = date('j', strtotime('+ 48 hours'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Coming from PHP world, I used to create select box like this: <select> <?php
I'm trying to create a drop down select option using PHP, MySQL, and ajadx
I current have this code that shows/hides content based on a select option. How
i have this code to create a select list in drupal dynamically. $res =
I am trying to create a function to run when a select option is
I'm using iBATIS to create select statements. Now I would like to implement the
I am trying to create a select list starting from the current date of
I'm new to this so bear with me. I'm trying to create a select
Suppose I want to create a select box in PHP. $months = array ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
I would like to create another select box from a select box value. through

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.