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 8061493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:21:26+00:00 2026-06-05T10:21:26+00:00

I have a database table with columns ‘name’ (of an event) and ‘day’ (in

  • 0

I have a database table with columns ‘name’ (of an event) and ‘day’ (in full, so: ‘Monday, ‘Tuesday’ etc). In a while loop displaying an event followed by its day in brackets is quite straightforward.

Is there a way to systematically substitute each day for the date that that day falls on next? So Monday would be 11 Jun, Tuesday would be 12 Jun, etc.

I’ve tried something along these lines, but the variable stays the same for each row of ‘name’ – retrospectively this makes sense.

$today = date("l");
$todays_date = date("j M");

if ($row['day'] == $today) {
    $date = $todays_date;
    }

else if (day == date("l", strotime("+1 day")) {
    $date = date("j M", strotime("+1 day"));
    }

echo "<option>" . $row['name'] . " (" . $date . ")</option>";

EDIT

Here’s what I now have:

function getClubs() {
connect();

date_default_timezone_set('Europe/London');

$day = date("l");
$time = date("G");

if ($time >= 21) {
    $day = date('l', strtotime($day .' +1 day'));
    }


if ($day == Monday) {
    $query = "SELECT * FROM nights WHERE city = 'Cambridge' ORDER BY FIELD(day, 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY')";
    }

else if ($day == Tuesday) {
    $query = "SELECT name FROM nights WHERE city = 'Cambridge' ORDER BY FIELD(day, 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY', 'MONDAY')";
    }

else if ($day == Wednesday) {
    $query = "SELECT name FROM nights WHERE city = 'Cambridge' ORDER BY FIELD(day, 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY', 'MONDAY', 'TUESDAY')";
    }

else if ($day == Thursday) {
    $query = "SELECT name FROM nights WHERE city = 'Cambridge' ORDER BY FIELD(day, 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY')";
    }

else if ($day == Friday) {
    $query = "SELECT name FROM nights WHERE city = 'Cambridge' ORDER BY FIELD(day, 'FRIDAY', 'SATURDAY', 'SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY')";
    }

else if ($day == Saturday) {
    $query = "SELECT name FROM nights WHERE city = 'Cambridge' ORDER BY FIELD(day, 'SATURDAY', 'SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY')";
    }

else if ($day == Sunday) {
    $query = "SELECT name FROM nights WHERE city = 'Cambridge' ORDER BY FIELD(day, 'SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY')";
    }


    $result = mysql_query($query);
    $items = array();

    if($result && mysql_num_rows($result) > 0) { 
        while ($row = mysql_fetch_array($result)) { 
//          $items[] = array($row['name']);

$day = $row['day'];

function getDateString($day){
    if (date("l")==$day){
        return date("j M");
    }
    else {
        $date = strtotime("next $day");
        return date("j M",$date);
    }
}

            echo "<option>" . $row['name'] . " (" . getDateString($row['day']) . ")</option>";

            }         
    }
}
  • 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-06-05T10:21:28+00:00Added an answer on June 5, 2026 at 10:21 am

    You can use strtotime() to get this, for example:

    $date = strtotime('next tuesday');
    

    You would then use date() to convert it to a string (such as 12 Jun):

    date("j M",$date);
    

    Also if the event is today and you want it to display the current date you’d add some checking code, so all together as a function:

    function getDateString($day){
        if (date("l")==$day){
           return date("j M");
        } else {
           $date = strtotime("next $day");
           return date("j M",$date);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database with many tables and one particular table has columns: name
I have a database table with 3 columns: _id, name, groupName It looks similar
One of my database table columns have name like 'name@from' how can i write
Say I have a database table with three columns: ID, Name, and Age. I
Suppose I have a database table with columns a, b, and c. I plan
Lets say we have a database table with two columns, entry_time and value. entry_time
I have one database table which contains 8 columns. One of the columns is
I have a java class containing all the columns of a database table as
I have two columns(column1, column2) in my oracle database table named as demo .
I have 3 columns in Oracle database having table mytable and i want records

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.