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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:27:07+00:00 2026-05-27T18:27:07+00:00

I have in PHP: <?php $columns = array(‘mon’,’thu’,’wed’,’tue’, ‘fri’, ‘sat’, ‘sun’); $num_cols = count($columns);

  • 0

I have in PHP:

<?php

$columns = array('mon','thu','wed','tue', 'fri', 'sat', 'sun');
$num_cols = count($columns);
$col = 0;
$datetime = new DateTime("06:00");

echo "<table>"; // border=\"1\" for visible border

// Day header
echo "<tr>";
foreach($columns as $col) {
    echo "<td at='$col'>$col</td>";
}
echo "</tr>";


// Times
for($i=0; $i<20; $i++) { // FIXME for more entries or other step width
    echo "<tr>";
    $datetime->modify('+30 minutes');

    for ($j=0; $j<$num_cols; $j++)
        echo '<td class="' . $datetime->format('H:i') . '">' . $datetime->format('H:i') . '</td>';

    echo "</tr>";
}

echo "</table>";

?>

and in database MySQL:

id | day | hours
1  | mon | 07:00
2  | thu | 08:40
3  | wed | 12:30
4  | thu | 13:00
5  | fri | 05:00
etc

how is the best method for checking this? If date is in database then i would like make TD with red background, for example add class red:

echo "<td at='$col' class='red'>$col</td>";

Check this in each loop FOR is not good idea – this generated to many query for database.
How can i make it?

I can use also jquery and for example JSON if this is possible.

  • 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-27T18:27:08+00:00Added an answer on May 27, 2026 at 6:27 pm

    List them all in a keyed array, then when looping through the calendar simply check for these keys.

    For example, you’d get the array array(1 => array('07:00' => true)) (day of the week => appointments).

    You can then check isset($array[$datetime->format('N')][$datetime->format('H:i')])

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

Sidebar

Related Questions

Right now I have this PHP: $columns = array(*/Data*/); echo json_encode($columns); And this is
I have a php form that has a known number of columns (ex. top
I have a php page that produces an array of elements. For the sake
I have SQLite table with columns id and name. I return array of those
I have this PHP one dimensional array: Array ( [Female--N] => 11 [Male--N] =>
I have some PHP 5.3 code which builds an array to be passed to
I have some PHP code which allows me to sort a column into ascending
I have PHP configured so that magic quotes are on and register globals are
We have PHP 5.2.6 deployed to c:\php and in that folder there is the
I have PHP 5.1.6 running with a ton of mods and extensions enabled, 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.