Highlight td elements with events - php

I am generating a calendar via PHP date() function, I also have an events table that has a name and date_start, what I want to do is to highlight the td elements that have events on them and leave the ones without with the basic formatting.
Basically, this is the script that loops the day:
<?php
echo "<tr>";
for ($i = 1; $i < $numDays+1; $i++, $counter++) {
$timeStamp = strtotime ("$year-$month-$i");
if($i == 1){
$firstDay = date ("w", $timeStamp);
for ($j = 0; $j < $firstDay; $j++, $counter++){
//blank space
echo "<td> </td>";
}
}
if($counter % 7 == 0 ){
echo "<tr></tr>";
}
$todayDate = date("Y-m-d");
if (date("Y-m-d", $timeStamp) == $todayDate) {
?>
<td class="today-date"><?php echo $i; ?></td>
<?php
} else {
?>
<td><?php echo $i; ?></td>
<?php
}
}
echo "</tr>";
?>
.today-date is a class to highlight the current day. This is my table columns:
id | name | description | date_start | date_end | time | pastor_id | pastor | category | venue

I would probably put my events into an array with a key for the start date, so you end up with something like:
$events = [
'2017-08-22' => [
'name' => 'Event Title',
],
'2017-08-28' => [
'name' => 'Event Title',
'name' => 'Event Title',
],
];
There are multiple ways of doing this from a DB. Something like this:
$events = [];
while($row = mysql_fetch_assoc($eventQuery))
{
$events[$row['start_date']][] = $row['name'];
}
Then in your loop, you can check the date for an event and put it in:
<td class="<?php echo (array_key_exists(date("Y-m-d", $timeStamp), $events)) ? 'has-event-class' : ''; ?>">
Making database queries for every day in the calendar will be very inefficient compared to pulling all, or even the months'.
I would also be inclined to move this into a function so it's not as long in your loop:
function highlightEventTD($timeStamp, $events)
{
$date = date("Y-m-d", $timeStamp);
return (array_key_exists($date, $events)) ? 'has-event-class' : '';
}
Then in your forloop:
<td class="<?php echo highlightEventTD($timeStamp, $events); ?>">
It also means that if you need to show the name of the event, you can use the same array and a function:
function getEvents($timestamp, $events)
{
$date = date("Y-m-d", $timeStamp);
return (array_key_exists($date, $events)) ? $events[$date] : null;
}

Ok, first of all, PHP7 doesn't like anymore open and close php tag many times... I changed syntax with echo.
So try this :
// here make a SQL query (only one query is enough)
// on your database, for example :
$dates = array();
$q = "SELECT * FROM `events`";
if($res = $pdo->query($q) {
if($res = $res->fetchAll(PDO::FETCH_OBJ)) {
if(sizeof($res) > 0) {
foreach($res as $k => $d) {
$events[$d['date_start']] = $d;
}
}
}
}
echo "<tr>";
for ($i = 1; $i < $numDays + 1; $i++, $counter++) {
$timeStamp = strtotime ("$year-$month-$i");
if($i == 1){
$firstDay = date ("w", $timeStamp);
for ($j = 0; $j < $firstDay; $j++, $counter++) {
echo "<td> </td>"; //blank space
}
}
if($counter % 7 == 0 ) {
echo "<tr></tr>";
}
if (date("Y-m-d", $timeStamp) == date("Y-m-d")) {
$class = "today-date ";
}
if (array_key_exists(date("Y-m-d"), $events)) {
$class .= "event-date ";
}
// 1. solution based on your code
echo "<td class=\"$class\">$i</td>";
// 2. alternative with events in each day :
echo "<td class=\"$class\">";
if(sizeof($eventsOfTheDay = $events[$d['date_start']]) > 0 {
foreach($eventsOfTheDay as $k => $event) {
echo '', $event['name'], '<br>';
}
}
echo "</td>";
}
echo "</tr>";

Related

Comparing and outputting dates from an array and a MySQL query using PHP

Recently I posted this question (Converting day of week to dates for the current month with MYSQL & PHP) and got many helpful replies.
I'd like to build on this and do something more but again am reaching the limits of my knowledge and am looking for some guidance.
Purpose:
I have weekly recurring events/attendance, which I am able to match and display with the date of the current month thanks to above. Also, I have a database of cancellations/date changes to these weekly recurring events/attendance.
I'd like to match these two to display in one table.
Here's the current situation:
As you can see I'm making this for mobile. Currently I show the set schedule on top with the bottom displaying the cancellations (in red) and the one-off reservations to other events (in green).
Here's my code for the first part:
$sql = "SELECT StudentDB.studentid, ClassDB.classID, ClassDB.class_level, ClassDB.class_title, ClassDB.time, ClassDB.teacher, StudentDB.first_name, StudentDB.last_name, StudentDB.payment_amount, ClassDB.day
FROM ClassDB
INNER JOIN RegDB ON ClassDB.classID = RegDB.classid
INNER JOIN StudentDB ON StudentDB.studentID = RegDB.studentid
WHERE StudentDB.studentid = '$studentid'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table class='table table-hover'>";
echo "<tr><th colspan=2 class='text-center'>固定レッスン</th></tr><tr><th>クラス</th><th>開始時間</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
$dayofclass = $row['day'];
echo "<tr><td>".$row["class_level"]." ".$row["class_title"]."</td><td>".$row['day']." ".$row['class_time']." " .$row['time']. "</td></tr>";
}
$n=date('t',strtotime($date)); // find no of days in this month
$yearmonth = date("Y-m-");
$dates=array();
for ($i=1;$i<=$n;$i++){
if ($i<10) {
$i = "0" . $i;
}
$day=date("l",strtotime($yearmonth.$i)); //find weekdays
if($day==$dayofclass){
$dates[]=$yearmonth.$i;
}
}
$arrlength = count($dates);
for($x = 0; $x < $arrlength; $x++) {
$y = $x +1;
echo "<tr><td>Week ".$y."</td><td>".$dates[$x]."</td></tr>";
}
echo "</table>";
}
And code for the second part:
$sql = "SELECT AttendanceDB.*, ClassDB.*
FROM StudentDB
INNER JOIN AttendanceDB ON StudentDB.studentid = AttendanceDB.studentid
INNER JOIN ClassDB ON AttendanceDB.classid = ClassDB.classID
WHERE StudentDB.studentid = '$studentid' AND AttendanceDB.class_time >= '$date'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table class='table table-hover'>";
echo "<tr><th colspan=2 class='text-center'>振替の予定</th></tr><tr><th>クラス</th><th>開始時間</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
$phpdate = strtotime( $row["class_time"] );
$mysqldate = date( 'Y-m-d', $phpdate );
if ($row["furikae"] == 3){
echo "<tr class=success><td>振替(".$row["class_level"]." ".$row["class_title"].")</td><td>".$mysqldate." " .$row['time']. "</td></tr>";
} elseif ($row["furikae"] == 8) {
echo "<tr class=warning><td>承認待ち</td><td>".$mysqldate." " .$row['time']. "</td></tr>";
} elseif ($row["furikae"] == 2) {
echo "<tr class=danger><td>休み</td><td>".$mysqldate." " .$row['time']. "</td></tr>";
}
}
}
The first set of data is being stored in an array. I assume what I need to do is input things into an array in the second stage and then then compare the information in those two arrays, merge them into one, have another array corresponding to the first which tags the data in the first with things like "absent," then output the the new arrays in a master list?
Is this right? I'm having trouble conceptualizing how to make this code work.
Thanks in advance.
Spent some time educating myself and came up with this (query 1):
if ($result->num_rows > 0) {
echo "<table class='table table-hover'>";
echo "<tr><th colspan=2 class='text-center'>固定レッスン</th></tr><tr><th>クラス</th><th>開始時間</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
$dayofclass = $row['day'];
echo "<tr><td>".$row["class_level"]." ".$row["class_title"]."</td><td>".$row['day']." ".$row['class_time']." " .$row['time']. "</td></tr>";
}
$n=date('t',strtotime($date)); // find no of days in this month
$yearmonth = date("Y-m-");
$dates=array();
for ($i=1;$i<=$n;$i++){
if ($i<10) {
$i = "0" . $i;
}
$day=date("l",strtotime($yearmonth.$i)); //find weekdays
if($day==$dayofclass){
$dates[]=$yearmonth.$i;
$datesdata[$yearmonth.$i] = "0";
}
}
echo "</table>";
}
(query 2):
if ($result->num_rows > 0) {
echo "<table class='table table-hover'>";
echo "<tr><th colspan=2 class='text-center'>今月の予定</th></tr><tr><th>クラス</th><th>開始時間</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
$phpdate = strtotime( $row["class_time"] );
$mysqldate = date( 'Y-m-d', $phpdate );
if ($row["furikae"] == 3){
$dates[]=$mysqldate;
$datesdata[$mysqldate] = "1";
} elseif ($row["furikae"] == 8) {
$dates[]=$mysqldate;
$datesdata[$mysqldate] = "3";
} elseif ($row["furikae"] == 2) {
$dates[]=$mysqldate;
$datesdata[$mysqldate] = "2";
}
}
ksort($datesdata);
foreach ($datesdata as $key => $val) {
if ($val == 0){
echo "<tr><td>参加予定</td><td>".$key."</td></tr>";
} elseif ($val == 1) {
echo "<tr class='success'><td>振替参加予定</td><td>".$key."</td></tr>";
} elseif ($val == 2) {
echo "<tr class='danger'><td>休み予定</td><td>".$key."</td></tr>";
} elseif ($val == 3) {
echo "<tr class='warning'><td>キャンセル待ち</td><td>".$key."</td></tr>";
}
}
}
This is probably not the cleanest way to do it, but it works. I put the dates into an array with the key set to the date and the value set to some number referencing attendance (attending, absent, uncertain). Dates from both queries (the regular attendance results and the irregular reservations) are put into the array, then reordered by date using ksort, then output based on the reservation status.

How to complete my calendar properly when there is more than 1 event?

I need some help for display the events when there is more than 1.
Currently my calendar looks like that:
I've done a while for each events but I don't know how to tell to PHP to do the others events and not repeat the same one 2 or 3 times like on the screenshot.
Here is my current code: (working perfectly with only 1 event per person)
$chresult = mysql_query("SELECT * FROM personnel WHERE masquer=0 ORDER BY lastname");
$z = 0;
while ($z < mysql_num_rows($chresult)) {
$lastname = $donnees['lastname'] = mysql_result($chresult, $z, 'lastname');
$firstname = $donnees['firstname'] = mysql_result($chresult, $z, 'firstname');
$personnel_id = $donnees['personnel_id'] = mysql_result($chresult, $z, 'personnel_id');
$abresult = mysql_query("SELECT motif, date_start, date_end FROM absence WHERE personnel_id='$personnel_id' AND date_start>='$startmonth' AND date_end<='$endmonth' ORDER BY id DESC");
$rowabsence = mysql_fetch_row($abresult);
$resultcountpersonnelabsent=mysql_query("SELECT COUNT(*) AS nombre FROM absence WHERE personnel_id='$personnel_id' AND date_start>='$startmonth' AND date_end<='$endmonth' ORDER BY id DESC");
$number=mysql_result($resultcountpersonnelabsent, 0, 'nombre');
if($number == 0) {
}
else {
echo "<TR>";
echo "<TD><span class=\"label label-default\">$lastname $firstname</span></TD>";
$w = 0;
while ($w < $number) {
$explode_date_start=explode('-',$rowabsence[1]);
$explode_date_end=explode('-',$rowabsence[2]);
$numberofdays = $explode_date_end[2] - $explode_date_start[2];
$explode_end_month=explode('-',$endmonth);
$a = 1;
while ($a < $explode_date_start[2]) {
echo "<TD></TD>";
$a++;
}
$b = -1;
while ($b < $numberofdays) {
echo "<TD bgcolor=\"$color\"></TD>";
$b++;
}
$c = $explode_date_end[2];
while ($c < $explode_end_month[2]) {
echo "<TD></TD>";
$c++;
}
$w++;
}
echo "</TR>";
}
$z++;
}
EDIT: Translated PHP code from French to English.
P.S: When this will be fully working I will upload the full source if requested.

Check for multiple rows - PHP & MySQL

I am cycling through cells in a HTML table using PHP to color specific cells.
I want to color the cells that return true to this statement:
if ($currentCell >= $reservationStartDayOfMonth && $currentCell <= $reservationEndDayOfMonth) {
make red
} else {
make normal color
}
This is not the exact statement, but the idea of it.
I get the reservationEndDayOfMonth and reservationStartDayOfMonth from a MySQL server.
For each row in the SQL server, there is a new reservation with a start and an end date. Along with the id (1...2...3...)
Basically I got a reservation in the current month. And it works when I just cycle through the cells with the data from ONE reservation. But I got lots of reservations in my database. I need to check and see if the current cell corresponds to any of the many reservations I have.
My code is long and bulky. It's basically just a table with all the checkers and parameters inside. Here you go:
<table border="1" id="calendar">
<?php
$dk_database = array("Januar","Februar","Marts","April","Maj","Juni","Juli","August","September","Oktober","November","December");
$dk_month = $dk_database[(int)date("m")-1];
ECHO '<caption><h1 style="color:#554100;">' . $dk_month . '</h1></caption>';
$sqldateStart = sqlRequest("SELECT res_datestart FROM spottrup_reservations WHERE res_id = 1");
$dateStartRaw = mysql_fetch_array($sqldateStart);
$dateStartArray = explode("-", $dateStartRaw[0]);
$dateStartDay = (int)$dateStartArray[2];
$dateStartMonth = (int)$dateStartArray[1];
$dateStartYear = (int)$dateStartArray[0];
$sqldateEnd = sqlRequest("SELECT res_dateend FROM spottrup_reservations WHERE res_id = 1");
$dateEndRaw = mysql_fetch_array($sqldateEnd);
$dateEndArray = explode("-", $dateEndRaw[0]);
$dateEndDay = (int)$dateEndArray[2];
$dateEndMonth = (int)$dateEndArray[1];
$dateEndYear = (int)$dateEndArray[0];
$currentYear = (int)date("y")+2000;
$currentDate = (int)date("d");
$currentMonth = (int)date("m");
$columnsInRow = 7;
$daysInMonth = date("t");
$currentDay = 1;
for ($i=0 ; $i < $daysInMonth ; $i++) {
ECHO '<tr class="cal">';
for ($j=0 ; $j < $columnsInRow && $currentDay <= $daysInMonth ; $j++) {
if($currentDate==$currentDay) {
if($currentDay>=$dateStartDay && $currentDay<=$dateEndDay && $currentMonth==$dateStartMonth && $currentYear==$dateStartYear) {
ECHO '<div style="background:blue;height:100%;width:100%text-decoration:none;"><td class="cal"><h2 style="color:red;">' . $currentDay . '</h2></td></div>';
}else{
ECHO '<div style="background:#D4BB6A;height:100%;width:100%text-decoration:none;"><td class="cal"><h2 style="color:red;">' . $currentDay . '</h2></td></div>';
}
}else{
if($currentDay>=$dateStartDay && $currentDay<=$dateEndDay && $currentMonth==$dateStartMonth && $currentYear==$dateStartYear) {
ECHO '<div style="background-color:blue;height:100%;width:100%text-decoration:none;"><td class="cal" style="background-color:#FF8080;"><h2 style="color:#554100;">' . $currentDay . '</h2></td></div>';
}else{
ECHO '<div style="background-color:#D4BB6A;height:100%;width:100%text-decoration:none;"><td class="cal"><h2 style="color:#554100;">' . $currentDay . '</h2></td></div>';
}
}
$currentDay++;
}
ECHO '</tr>';
}
?>
The sqlRequest(string); calls a function that returns the result of the query you give.
Not the most efficient way since lots of queries but it does reduce a for loop, but you could run a query for each day to see if there is a reservation for it. Simple to implement.
for ($i=0 ; $i < $daysInMonth ; $i++)
{
...
$query = "Select * from table where currentDate >= startDate and currentDate <= endDate"
...
}

schedule: click book time slot to display image of specific user that is booking? HOW PLEASE?

Ok, i have my php code wrote out for the schedule to book time slots. The sql is pulling the user name (text) and displaying it, BUT I AM NOW TRYING TO DISPLAY THE USERS PIC IMAGE INSTEAD OF JUST NAME(text). I cant for the life of me find anything that is clearly telling me how to display an image on click instead of the text from sql. PLEASE HELP, THANKS :)
ENTIRE CODE:
<?php require('head.php');?>
<?php
// Basic info
$slotb = $_GET['slot'];
$day = $_GET['day'];
// User info
$username = $_SESSION['rp_username'];
$avatar = $_SESSION['rp_avatar'];
$rank = $_SESSION['rp_rank'];
// Get user's ID
$sql = mysql_query("SELECT id, username FROM rp_users WHERE username = '$username'");
while($row = mysql_fetch_array($sql))
{
$userid = $row['id'];
}
// Determine day of week
if($_GET['week'] == "")
{
$_GET['week'] = date("l");
}
// Determine day of week
if($_GET['day'] == ""){
$day = $_GET['week'];
$_GET['week'] = date("l");
}
// Get slot info
$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
// Timetable heading
echo "<div id='timetable'><center><b><u>Timetable</u></b><p>
<h1>-You are currently viewing $day's timetable-</h1><p>
<a href='?week=Monday'>Monday</a> | <a href='?week=Tuesday'>Tuesday</a> | <a href='? week=Wednesday'>Wednesday</a> | <a href='?week=Thursday'>Thursday</a> | <a href='? week=Friday'>Friday</a> | <a href='?week=Saturday'>Saturday</a> | <a href='? week=Sunday'>Sunday</a><br><hr><br>";
// Process booking
if($_GET["action"] == "book")
{
if($slot[$slotb] == "")
{
$command = mysql_query("UPDATE rp_timetable SET `$slotb` = '$userid' WHERE day = '$day'") or die(mysql_error());
if($command)
{
echo "<center><h1>Successfully booked slot!</h1></center><br/>";
$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
}else{
echo "<center><h1>ERROR - An unknown error occurred, please try again.</h1></center> <br/>";
}
}else{
echo "<center><h1>The selected slot is already booked!</h1></center><br/>";
}
}elseif($_GET["action"] == "unbook")
{
if($slot[$slotb] == $userid || $rank == "Administrator")
{
$command = mysql_query("UPDATE rp_timetable SET `$slotb` = '' WHERE day = '$day'") or die(mysql_error());
if($command)
{
echo "<center><h1>Successfully unbooked slot!</h1></center><br/>";
$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
}else{
echo "<center><h1>ERROR - An unknown error occurred, please try again.</h1></center> <br/>";
}
}else{
echo "<center><h1>You cannot unbook this slot!</h1></center><br/>";
}
}
elseif($_GET["action"] == "empty"){
if($rank == "Administrator")
{
$command = mysql_query("UPDATE rp_timetable SET `1`='', `2`='', `3`='', `4`='', `5`='', `6`='', `7`='', `8`='', `9`='', `10`='', `11`='', `12`='', `13`='', `14`='', `15`='', `16`='', `17`='', `18`='', `19`='', `20`='', `21`='', `22`='', `23`='', `24`='' WHERE day='$day'") or die(mysql_error());
if($command)
{
echo "<center><h1>Successfully cleared all slots for day!</h1></center><br/>";
$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
}else{
echo "<center><h1>ERROR - An unknown error occurred, please try again.</h1></center><br/>";
}
}
else{
echo "<center><h1>Only administrators may unbook all slots for the day!</h1></center> <br/>";
}
}
// Start of timetable
echo "<table border='0' valign='middle' align='center'><tr>
<td width='150px' align='center'><b><u>Time</u></b></td>
<td width='150px' align='center'><b><u>DJ Booked</u></b><td></tr>
<tr><td></td><td></td></tr>";
// Display each timeslot/table
function outit($time, $num)
{
global $day, $slot, $userid, $rank;
$info = mysql_fetch_array(mysql_query("SELECT * FROM rp_users WHERE id = '".$slot[$num]."'"));
if($slot[$num] == "")
{
$book[$num] = "<a href='?action=book&day=$day&slot=$num'>BOOK SLOT</a>";
}
elseif($userid == $slot[$num] || $rank == "Administrator")
{
$book[$num] = "<a href='?action=unbook&day=$day&slot=$num'><b>DJ ".$info['avatar']." (Unbook)</a></b>";
}else{
$book[$num] = "<b><font color='black'>DJ ".$info['avatar']."</font></b>";
}
if($num%2)
{
echo "<tr class='colour'><td width='150px' align='center'>$time</td><td width='150px' align='center'>".$book[$num]."<td></tr>";
}else{
echo "<tr><td width='150px' align='center'>$time</td><td width='150px' align='center'>".$book[$num]."<td></tr>";
}
}
// Print it out
outit('12:00 - 01:00 AM', 1);
$i = 2;
while($i <= 12)
{
$start_time = $i - 1;
$end_time = $i;
if(strlen($start_time) == 1){$start_time = "0".$start_time;}
if(strlen($end_time) == 1){$end_time = "0".$end_time;}
$full_time = "$start_time:00 - $end_time:00 AM";
outit($full_time, $i);
$i++;
}
outit('12:00 - 01:00 PM', 13);
$i = 14;
while($i <= 24)
{
$start_time = $i - 13;
$end_time = $i - 12;
if(strlen($start_time) == 1){$start_time = "0".$start_time;}
if(strlen($end_time) == 1){$end_time = "0".$end_time;}
$full_time = "$start_time:00 - $end_time:00 PM";
outit($full_time, $i);
$i++;
}
// Bottom of timetable
echo "<tr><td align='center'>---------------</td><td align='center'>--------------- </td></tr>";
echo "<tr><td width='150px' align='center'><b>$day</b></td>
<td width='150px' align='center'>";
if ($_SESSION["rp_rank"] == "Administrator")
{
echo("<a href='?action=empty&day=$day'>CLEAR DAY</a>");
}
echo "</td></tr></table>
</center><p></div>";
?>
<?php require('bottom.php');?>
To use the $avatar variable that seems to be stored in your session:
echo '<img src="'.$avatar.'"></img';
You also seem to be selecting that field in the query $info, meaning you should be able to use the following as well:
echo '<img src="'.$info['avatar'].'"></img';
To isolate the problem, please let me know what output you get for just the following:
<?php require('head.php');?>
<?php
// Basic info
$slotb = $_GET['slot'];
$day = $_GET['day'];
// User info
$username = $_SESSION['rp_username'];
$avatar = $_SESSION['rp_avatar'];
$rank = $_SESSION['rp_rank'];
echo $avatar;
<?php require('bottom.php');?>
My guess is that $avatar holds apostrophes or other characters that need to be escaped.
Also could you provide a couple examples of the field values for the avatar column on the rp_users table? If they contain apostrophes, then that is your answer.

I have an issue with my loops to show the result

$array_of_time = array ();
$start_time = strtotime ("$app_date 07:00");
$end_time = strtotime ("$app_date 22:00");
$mins = 04 * 60;
while ($start_time <= $end_time)
{
$array_of_time[] = date ('h:i a', $start_time);
$start_time += $mins;
}
echo "<div style='width:700px' class='time_slot_div'>";
echo "<p class='time_slot_p'> Time Slot :</p>";
foreach($array_of_time as $key=>$value)
{
for($i = 0; $i < count($app_data); $i++)
{
$book_time=$app_data[$i]["appointment_time"];
if($value==$book_time)
{
echo "<a class='time_slot_a_book'>$value</a> ";
} else {
echo "<a href='#' onclick='get_time_value(\"$value\");' class='time_slot_a'>$value</a> ";
}
}
}
echo "</div>";
Here foreach loop can run as many time as it can as well as for loop also, but i want to show the links that are not matched with the foreach value and for loop value.
The foreach loop values like 7:20 am not from database but the for loop value like 7:20 am is from database so if 7:20 am==7:20 am then the if statement it run it is working fine, but the issue is that it is running 2 time if i get 2 value in for loop. It should run my div only once.
Use a array to store the item that has shown.
<?php
foreach($array_of_time as $key=>$value)
{
$tag_list = array();
for($i = 0; $i < count($app_data); $i++)
{
$book_time=$app_data[$i]["appointment_time"];
// shown, skip
if (isset($tag_list[$book_time]))
{
continue;
}
// mark as show
$tag_list[$book_time] = 1;
if ($value == $book_time)
{
echo "<a class='time_slot_a_book'>$value</a> ";
}
else
{
echo "<a href='#' onclick='get_time_value(\"$value\");' class='time_slot_a'>$value</a> ";
}
}
}

Categories