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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:00:09+00:00 2026-06-06T16:00:09+00:00

Let’s imagine that I have to make a table with the following structure with

  • 0

Let’s imagine that I have to make a table with the following structure with PHP. Every cell identified with NamedayHour
is just an indicator ( Mon0, Mon1, and so on for every day ). I should put information on that cells, that is different for every day and hour.

The whole structure is something like this :

<table border="1" >
<th>Hour</th>
<th>Mon 25-06-2012</th>
<th>Tue 26-06-2012</th>
<th>Wed 27-06-2012</th>
<th>Thu 28-06-2012</th>
<th>Fri 29-06-2012</th>
<tr><td>8:00</td><td>Mon0</td><td>Tue0</td><td>Wed0</td><td>Thu0</td><td>Fri0</tr>
<tr><td>8:20</td><td>Mon1</td><td>Tue1</td><td>Wed1</td><td>Thu1</td><td>Fri1</tr>
<tr><td>8:40</td><td>Mon2</td><td>Tue2</td><td>Wed2</td><td>Thu2</td><td>Fri2</tr>
<tr><td>9:00</td><td>Mon3</td><td>Tue3</td><td>Wed3</td><td>Thu3</td><td>Fri3</tr>
<tr><td>9:20</td><td>Mon4</td><td>Tue4</td><td>Wed4</td><td>Thu4</td><td>Fri4</tr>
<tr><td>9:40</td><td>Mon5</td><td>Tue5</td><td>Wed5</td><td>Thu5</td><td>Fri5</tr>
</table>    

So, I have the arrays:

$hoursMonday = array("8:00", "8:20", "8:40")
$hoursMondayAssigned = array("8:00", "8:20")
$hoursMondayAvailable = array("8:40")

I have these 3 arrays for every day from Monday to Friday.

Then I need to write the hours in the table for every day. For example, in this case, I need to put on the cell for Monday and hour: 8:40 the text
“Available”, and for “8:00” and “8:20” I should put on the column Monday for these hours, the system should put “Busy” for both of them.

The resulting table, using the arrays of the example, should be like the following table:

<table border="1" >
<th>Hour</th>
<th>Mon 25-06-2012</th>
<th>Tue 26-06-2012</th>
<th>Wed 27-06-2012</th>
<th>Thu 28-06-2012</th>
<th>Fri 29-06-2012</th>
<tr><td>8:00</td><td>BUSY</td><td>Tue0</td><td>Wed0</td><td>Thu0</td><td>Fri0</tr>
<tr><td>8:20</td><td>BUSY</td><td>Tue1</td><td>Wed1</td><td>Thu1</td><td>Fri1</tr>
<tr><td>8:40</td><td>AVAILABLE</td><td>Tue2</td><td>Wed2</td><td>Thu2</td><td>Fri2</tr>
<tr><td>9:00</td><td>Mon3</td><td>Tue3</td><td>Wed3</td><td>Thu3</td><td>Fri3</tr>
<tr><td>9:20</td><td>Mon4</td><td>Tue4</td><td>Wed4</td><td>Thu4</td><td>Fri4</tr>
<tr><td>9:40</td><td>Mon5</td><td>Tue5</td><td>Wed5</td><td>Thu5</td><td>Fri5</tr>
</table>
</html>

I would like to use jQuery, or just PHP to solve this.

One of the things to note, is that the parameter of frequency ( in this case 10 minutes ) might vary. If the frequency is set to 30 minutes, for example,
the times will be: 8:00 , 8:30, 9:00, 9:30 and so on.

I don’t really know how to solve this using jQuery. I know how to write the table using a for loop, but complexity is leveling up when I need to
put the information on the correct cell depending of the day and hour.

Thanks.

  • 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-06T16:00:12+00:00Added an answer on June 6, 2026 at 4:00 pm

    You could do the following in PHP to find out for each hour if it’s assigned already or free:

    $hoursMonday = array("8:00", "8:20", "8:40");
    $hoursMondayAssigned = array("8:00", "8:20");
    $hoursMondayAvailable = array("8:40");
    
    foreach( $hoursMonday AS $hour ) {
        if( in_array( $hour, $hoursMondayAssigned ) ) {
            echo 'Busy at ' . $hour;
        } else if ( in_array( $hour, $hoursMondayAvailable ) ) {
            echo 'Free at ' . $hour;
        }
    }
    

    To automate looping through all the days I would suggest using a recursive array for each day, for example:

    $monday = array(
        'free' => array(
            '08:40', '09:00'
        ),
    
        'busy' => array(
            '08:40',
        ),
    
        'free' => array(
            '09:00',
        ),
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say we have a table that has 2 million rows. It has two
Let's assume I have the following structure: <div id=divid1> <div id=divid2> <div id=divid3> </div>
Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let me explain best with an example. Say you have node class that can
Let's say I have a table with a Color column. Color can have various
Let's say that I have a SQLite database that I create in a separate
Let's say I have thousands of users and I want to make the passwords
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Let's say I have the following object: var VariableName = { firstProperty: 1, secondProperty:

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.