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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:47:22+00:00 2026-06-01T22:47:22+00:00

This is for a timetable and what it does is displays the previous day’s

  • 0

This is for a timetable and what it does is displays the previous day’s timetable and who has booked each slot (this is for a radio station.)

At the moment it displays who has booked each slot in chronological order however I would like it to say the time next to each result. The query outputs 24 rows (which is from Midnight to 23:00) and next to each slot I would like it to say (00:00, 01:00, 02:00, 03:00… 21:00, 22:00 so on so forth.)

This is my current code:

<?php 
include("../config.php");

#// Timetable Clearup Variabls
$yesterday = strtotime('yesterday');
$yesterdow = date('l',$yesterday);

echo "<table width=\"580px\" class=\"board\" border=\>";

$order = "SELECT * FROM timetable WHERE day = '$yesterdow'";
$result = mysql_query($order);

// Error checking
if (!$result) {
  // output error, take other action
}
else {
  while ($row=mysql_fetch_array($result)){
     // Append all results onto an array
     $rowset[] = $row;
  }
}
    foreach ($rowset as $row) {
  echo "<tr><td>" . htmlspecialchars($row['username']) . "</td></tr>";
}



?> 

Can you help?

  • 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-01T22:47:23+00:00Added an answer on June 1, 2026 at 10:47 pm

    I think we’re all looking too hard at a VERY simple problem. You are already using SELECT * in your query, so you’re already fetching all three columns from your table. So now, all you need to do is add another cell to each row of your table.

    echo "<tr><td>" . htmlspecialchars($row['username']) . "</td><td>" . htmlspecialchars($row['time']) . "</td></tr>";
    

    And to make sure you are fetching your rows in the correct order, you should add an ORDER BY to your query:

    SELECT * FROM timetable WHERE day = '$yesterdow' ORDER BY time
    

    If you don’t specify an ORDER BY clause, you have no guarantee that you will get the results in any particular order.

    And one last thing, you are looping through the rows twice, unnecessarily. Get rid of the foreach loop and put the echo directly inside the while loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This has been a rather problematic issue on numerous occasions. We have alot of
I have an app that displays a timetable of certain ferry trips. If I
I know this has been asked before in several ways but none of the
Does this procedure accurately show the space used in a db? I'm doubting the
This is really just for my own use: I would like to be able
This somehow simple task is not so simple. I can get the number of
This should be simple, but the answer is eluding me. If I've got a
this is my code that I write it but I want to use LINQ
This was resolved. The statement was in another part of the stored procedure. The
This is probably a stupid question, but how much of a security risk is

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.