Incredible behaviour with strftime - php

I have this code:
function calendarDay ($month, $year)
{
$num = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$today = strtotime(date("Y-m-d"));
$result = array();
$str = "";
$strMonth = "";
for ($i = 0; $i < $num; $i++) {
$date = strtotime($year . "-" . $month . "-" . ($i + 1));
$day=strftime("%a", $date);
$month = strftime("%b", $date);
if ($today == $date) {
if ($day == "Sat" || $day == "Sun") {
$str .= "<th style='background-color:mediumseagreen'>" . $day. "</th>";
$strMonth = $strMonth . "<th style='background-color:mediumseagreen'>".($i + 1) . "-" . $month." ". "</th>";
}
else {
$str .= "<th style='background-color:#888888'>" . $day. "</th>";
$strMonth = $strMonth . "<th style='background-color:#888888'>".($i + 1) . "-" . $month." ". "</th>";
}
}
else if ($today != $date) {
if ($day == "Sat" || $day == "Sun") {
$str .= "<th style='background-color:mediumseagreen'>" . $day. "</th>";
$strMonth = $strMonth . "<th style='background-color:mediumseagreen'>".($i + 1) . "-" . $month." ". "</th>";
}
else {
$str .= "<th>" . $day. "</th>";
$strMonth = $strMonth . "<th>".($i + 1) . "-" . $month." ". "</th>";
}
}
$result = array_merge($result, array("Month" => $strMonth));
$result = array_merge($result, array("Day" => $str));
}
return $result;
}
When I delete the line which convert my numeric $month from parameters to string with strftime("%b", $date), It gives the good behaviour.
And when I add this line the var $day began to repeat 9 times the first day of the month... which is Tuesday, and can't get the solution, its a bug for me...

You're replacing the variable that you use in:
$date = strtotime($year . "-" . $month . "-" . ($i + 1));
So on the 2nd day of the month, instead of trying to parse 2019-1-2 you're parsing 2019-Jan-1. I'm not sure why, but when you use this format with a single-digit day, it always parses as if it's 2019-01-01.
The solution is to use a different variable.
function calendarDay ($month, $year)
{
$num = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$today = strtotime(date("Y-m-d"));
$result = array();
$str = "";
$strMonth = "";
for ($i = 0; $i < $num; $i++) {
$date = strtotime($year . "-" . $month . "-" . ($i + 1));
$day=strftime("%a", $date);
$monthName = strftime("%b", $date);
if ($today == $date) {
if ($day == "Sat" || $day == "Sun") {
$str .= "<th style='background-color:mediumseagreen'>" . $day. "</th>";
$strMonth = $strMonth . "<th style='background-color:mediumseagreen'>".($i + 1) . "-" . $monthName." ". "</th>";
}
else {
$str .= "<th style='background-color:#888888'>" . $day. "</th>";
$strMonth = $strMonth . "<th style='background-color:#888888'>".($i + 1) . "-" . $monthName." ". "</th>";
}
}
else if ($today != $date) {
if ($day == "Sat" || $day == "Sun") {
$str .= "<th style='background-color:mediumseagreen'>" . $day. "</th>";
$strMonth = $strMonth . "<th style='background-color:mediumseagreen'>".($i + 1) . "-" . $monthName." ". "</th>";
}
else {
$str .= "<th>" . $day. "</th>";
$strMonth = $strMonth . "<th>".($i + 1) . "-" . $monthName." ". "</th>";
}
}
$result = array_merge($result, array("Month" => $strMonth));
$result = array_merge($result, array("Day" => $str));
}
return $result;
}

Replace the code
$date = strtotime($year . "-" . $month . "-" . ($i + 1));
into
$date = strtotime($year . "-" . $month . "-" .str_pad(($i + 1), 2, '0', STR_PAD_LEFT) );

Oh my go thanks you all !!! a lot, i was searching what i'm doing wrong since several days...
Just a var name conflict with my numeric $month and the string month with strftime. So i replaced the name of the string one.
Bad mistake ! ^^

Related

Why can't get the value of weekend in php

I don't know what are the errors of this code because it's suddenly not accurate the showing value to the user like this:
$holidays = array();
$query_holiday = "SELECT * FROM holiday_tbl";
$result = mysqli_query($dbcon, $query_holiday);
while($row_holiday = mysqli_fetch_assoc($result))
{
array_push($row_holiday, $holidays);
}
if(strtotime(date("Y-m-d")) > strtotime($row['due_date']))
{
$currentDate = date("Y-m-d");
$days = (strtotime($currentDate) - strtotime($row['due_date'])) / 86400;
$daysTemp = $days;
for($i=1;$i<$days;$i++)
{
$currentDay = date("D", strtotime("+ ".$i." days"));
$date_loop = date("Y-m-d", strtotime("+ ".$i." days"));
if($currentDay == "Sun" || $currentDay == "Sat")
{
$daysTemp--;
}
else if(in_array($date_loop, $holidays))
{
$daysTemp--;
}
}
echo $daysTemp;
}
The current implementation is rather convoluted. In these cases I find it's always better to start over and try to simplify the logic as much as possible. Here is my take on your problem:
function calculate_days_late($due_date = '', $holidays = array(), $current_date = 'today') {
$days_late = 0;
// Get the timestamps for due date and current date
$current_date_ts = strtotime($current_date);
$due_date_ts = strtotime($due_date);
// If current date is not after due date then not late
if ($current_date_ts <= $due_date_ts) {
return $days_late;
}
$loop_date_ts = $current_date_ts;
while ($loop_date_ts > $due_date_ts) {
// If the looping date is not a weekend or holiday then count it
if ( ! in_array(date('D', $loop_date_ts), array('Sat','Sun'))
&& ! in_array(date('Y-m-d', $loop_date_ts), $holidays)) {
$days_late++;
}
$loop_date_ts = strtotime('-1 day', $loop_date_ts);
}
return $days_late;
}
// Test
echo '2017-09-05 = ' . calculate_days_late('2017-09-05', array(), '2017-09-05') . "\n";
echo '2017-09-06 = ' . calculate_days_late('2017-09-05', array(), '2017-09-06') . "\n";
echo '2017-09-07 = ' . calculate_days_late('2017-09-05', array(), '2017-09-07') . "\n";
echo '2017-09-08 = ' . calculate_days_late('2017-09-05', array(), '2017-09-08') . "\n";
echo '2017-09-09 = ' . calculate_days_late('2017-09-05', array(), '2017-09-09') . "\n";
echo '2017-09-10 = ' . calculate_days_late('2017-09-05', array(), '2017-09-10') . "\n";
echo '2017-09-11 = ' . calculate_days_late('2017-09-05', array(), '2017-09-11') . "\n";
echo '2017-09-12 = ' . calculate_days_late('2017-09-05', array(), '2017-09-12') . "\n";
echo '2017-09-13 = ' . calculate_days_late('2017-09-05', array(), '2017-09-13') . "\n";
Working example: https://eval.in/856018

php Switch/case doesn't work

I tried to find my answer in the other switch/case question. But i don't find the solution.
I got a switch that split my date values in 4 different quarters.
But when i want to print it out, it doesn't work. I don't know what i'm doing wrong.
is this a typo or?
Thanks in advance.
MY CODE
while (odbc_fetch_row($result)) { // while there are rows
$overweight = odbc_result($result, "Weight1") - 44000;
//$total_overweight += $overweight;
$date = date("Y-m-d", strtotime(odbc_result($result, "Date1")));
$companies[] = odbc_result($result, "String3");
$weight = odbc_result($result, "Weight1");
$item['nrplaat'] = odbc_result($result, "String1");
$item['tptcode'] = odbc_result($result, "String3");
$item['chrononr'] = odbc_result($result, "String15");
$item['projectcode'] = odbc_result($result, "String4");
$item['projectnaam'] = odbc_result($result, "String8");
$item['1eweging'] = $weight;
$item['overweighted'] = $overweight;
$item['date'] = $date;
$item['2eweging'] = odbc_result($result, "Weight2");
$item['netto'] = odbc_result($result, "Nett");
switch($weight){
case($weight > '44000' && $weight <= '44500'):
$item['class'] = 'lichtgroen';
case($weight > '44500' && $weight <= '45000'):
$item['class'] = 'groen';
case($weight > '45000' && $weight <= '46000'):
$item['class'] = 'donkergroen';
case($weight > '46000' && $weight <= '47000'):
$item['class'] = 'bruingroen';
case($weight > '47000' && $weight <= '48000'):
$item['class'] = 'lichtbruin';
case($weight > '48000' && $weight <= '49000'):
$item['class'] = 'bruin';
case($weight > '49000' && $weight <= '50000'):
$item['class'] = 'lichrood';
case($weight > '50000'):
$item['class'] = 'rood';
}
switch($date){
case($date > $s_year.'-'.$quart1 && $date <= $s_year.'-'.$quart2):
$item['quarter'] = '1'; //kwartaal 1
case($date > $s_year.'-'.$quart2 && $date <= $s_year.'-'.$quart3):
$item['quarter'] = '2'; ////kwartaal 2
case($date > $s_year.'-'.$quart3 && $date <= $s_year.'-'.$quart4):
$item['quarter'] = '3'; ////kwartaal 3
case($date > $s_year.'-'.$quart4 && $date <= $s_year.'-'.$end):
$item['quarter'] = '4'; ////kwartaal 4
}
//$item['quarter'] = 1; WHEN I DO THIS, ALL RESULTS WILL PRINT OUT!!!
switch($item['quarter']){
case '1':
print "<tr>\n";
print " <td>" . $item['nrplaat'] . "\n";
print " <td>" . $item['tptcode'] . "\n";
print " <td>" . $item['chrononr'] . "\n";
print " <td>" . $item['projectcode'] . "\n";
print " <td>" . $item['projectnaam'] . "\n";
print " <td>" . $item['1eweging'] . "\n";
print " <td>" . "<span class=\"status\">".$item['class']."</span>" ."\n";
print " <td>" . $item['overweighted'] . "\n";
print " <td>" . $item['date'] . "\n";
print " <td>" . $item['2eweging'] . "\n";
print " <td>" . $item['netto'] . "\n";
print "</tr>\n";
break;
}
}
Use break;
case($date > $s_year.'-'.$quart1 && $date <= $s_year.'-'.$quart2):
$item['quarter'] = '1';
break;
Perhaps it's because you don't have break; in each switch case.
Try to add some break;
See here for switch in php.
You should add a break; statement at the end of each case.
You should add 'break' after 'case'. it is very important if you have some 'case'. Please understand the concept of switch statements, you can learn from http://php.net/manual/en/control-structures.switch.php.
If you have some 'case' and you don't use 'break', it mean the next case will be proceed too. If you using 'break' after 'case', the switch process will finish and not proceed to next case. Maybe you should learn about 'continue' too :)

PHP Comparing 0 does not work

I'm trying to set a checkbox as checked in php based on an hour fields from a comma separated value string. It works well for 1-23 but for some reason hour 0 always displays as checked:
<?php
myhours = explode(",", substr($arruser['arhours'],0,strlen($arruser['arhours']) - 1));
$checked = "";
for($hour = 0; $hour <= 23; $hour++) {
if(count($myhours) > 0) {
for($h = 0; $h <= count($myhours); $h++) {
if((int)$hour == (int)$myhours[$h]) {
$checked = " checked ";
break;
}
}
} else {
$checked = "";
}
if(strlen($hour) == 1) {
echo "<td><input type=checkbox " . $checked . " value=" . $hour . " onchange=\"updatehour(" . $_REQUEST['user'] . ",this.checked, '" . $hour . "')\">0$hour:00</td>";
} else {
echo "<td><input type=checkbox " . $checked . " value=" . $hour . " onchange=\"updatehour(" . $_REQUEST['user'] . ",this.checked, '" . $hour . "')\">$hour:00</td>";
}
$checked = "";
}
?>
The problem is straightforward; look at the outer loop:
for ($hour = 0; $hour <= 23; $hour++) {
Consider only the first iteration, so $hour is int(0). Further in the code:
if(count($myhours) > 0) {
for($h = 0; $h <= count($myhours); $h++) {
Pay close attention to the loop condition:
$h <= count($myhours)
Consider the last iteration of that loop, so $h equals the size of your array.
if ((int)$hour == (int)$myhours[$h]) {
At this point $myhours[$h] is undefined because the array index is out of bounds (and a notice would have been emitted) and so (int)$myhours[$h] becomes (int)null which is int(0). The comparison is therefore always true when $hour has the value of int(0).
The solution is to change the loop condition to:
$h < count($myhours)
Not exactly and answer, but your code could be reduced to this:
$myhours = array(0, 10, 13, 20);
for($hour = 0; $hour <= 23; $hour++) {
echo '<td><input type="checkbox"' . ( in_array($hour, $myhours) ? ' checked' : '' ) . ' value="' . $hour . '" onchange="updatehour(' . $_REQUEST['user'] . ', this.checked, ' . $hour . ')">' . str_pad($hour, 2, '0', STR_PAD_LEFT) . ':00</td>';
}
No need for a second loop and more variables here. Also be aware to not output values from $_REQUEST directly without any check.
Demo
Try before buy
Problem solved. It was actually the count($myhours) that was causing the problem. Basically even with an empty string it still returns an array with 1 element. Changed to check if count($myhours) > 1 and everything is working as expected:
<?php
$myhours = explode(",", substr($arruser['arhours'],0,strlen($arruser['arhours']) - 1));
$checked = "";
for($hour = 0; $hour <= 23; $hour++) {
if(count($myhours) > 1) {
for($h = 0; $h <= count($myhours); $h++) {
if((int)$hour == (int)$myhours[$h]) {
$checked = " checked ";
break;
}
}
} else {
$checked = "";
}
if(strlen($hour) == 1) {
echo "<td><input type=checkbox " . $checked . " value=" . $hour . " onchange=\"updatehour(" . $_REQUEST['user'] . ",this.checked, '" . $hour . "')\">0$hour:00</td>";
} else {
echo "<td><input type=checkbox " . $checked . " value=" . $hour . " onchange=\"updatehour(" . $_REQUEST['user'] . ",this.checked, '" . $hour . "')\">$hour:00</td>";
}
$checked = "";
}
?>

sql query fetch error [duplicate]

This question already has answers here:
Reference: What is variable scope, which variables are accessible from where and what are "undefined variable" errors?
(3 answers)
Closed 3 years ago.
I'v got some code but keep getting error's also I'm new to php so any help would be great :)
Here's my code
<?php
// Create connection
$con = mysqli_connect("host","database","pswd");
// Database Connection Check
if (mysqli_connect_errno($con)) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
break;
}
echo "<table>";
echo nextweek("heren1kalender","Heren 1e Provinciale");
echo "</table>";
function nextweek($table, $ploegNaam) {
// Get this weeks dates (monday and sunday and month)
$current_day = date("N")
$days_to_sunday = 7 - $current_day;
$days_from_monday = $current_day - 1;
$monday = date("d", strtotime("- {$days_from_monday} Days"));
$sunday = date("d", strtotime("+ {$days_to_sunday} Days"));
$month = date("m", strtotime("+ {$days_to_sunday} Days"));
// SQL query
$result = mysqli_query($con,"SELECT datum, hoofd, thuisploeg, bezoekers FROM " . $table . " WHERE thuisploeg LIKE '%Lochristi%' OR bezoekers LIKE '%Lochristi%'");
while($row = mysqli_fetch_array($result)) {
$string ="";
// Get day and month from array
$dag = substr($row['datum'], 4, -6);
$maand = substr($row['datum'], 7, -3);
if ($dag >= $monday AND $dag <= $sunday AND $maand == $month) {
if (strpos($row['thuisploeg'],'Lochristi') !== false) {
$string .= "<tr>";
if (substr($row['hoofd'], 0, 1) >= 3) {
$string .= '<td class="win">' . $row['hoofd'] . "</td>";
}
else {
$string .= '<td class="loss">' . $row['hoofd'] . "</td>";
}
$string .= '<td>' . $ploegNaam . '</td>';
$string .= "<td><strong>VS</strong></td>";
$string .= '<td>' . $row['bezoekers'] . '</td>';
}
elseif (strpos($row['bezoekers'],'Lochristi') !== false) {
$string .= "<tr>";
if (substr($row['hoofd'], 0, 1) >= 3) {
$string .= '<td class="loss">' . $row['hoofd'] . "</td>";
}
else {
$string .= '<td class="win">' . $row['hoofd'] . "</td>";
}
$string .= '<td>' . $row['thuisploeg'] . '</td>';
$string .= "<td><strong>VS</strong></td>";
$string .= '<td>' . $ploegNaam . '</td>';
}
$string .= "</tr>";
}
}
return $string;
}
?>
And these are the PHP error's I'm getting:
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/a2902119/public_html/test.php on line 24
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/a2902119/public_html/test.php on line 26
Thanks for the help!
After fixing the other issues: Variable scope. $con is not available in the functions. Pass it in as an arg or rework into classes or something.
Your SQL connection doesn't seem correct.
It should have 4 parts.
$con=mysqli_connect(hostaddress,dbuser,dbpass,databasename);

Wrong calendar displaying after server crash

Few days ago server crashed and was down for few hours, after server become available, my calendar started to display wrong data. It had to show me current month and 5 next(half a year in total). Server data is correct. Any ideas whats wrong with calendar? Does mysql server time can make my calendar show wrong data?
if (!isset($_MONTH))
$_MONTH = 6;
if (isset($_POST['subscribe_month']))
$_MONTH = $class->_dig($_POST['subscribe_month']);
$sql = mysql_query("SELECT d.header, d.id FROM " . $class->_cfg['pfx'] . "workshops as w
LEFT JOIN " . $class->_cfg['pfx'] . "workshops_date as wd ON wd.cid=w.id
LEFT JOIN " . $class->_cfg['pfx'] . "dictionary as d ON d.id=wd.city
WHERE w.public='1' and wd.public='1' and wd.date_end>='" . date("Y-m-d") . "' a
nd wd.predprosomtr='0' " . $where . " ORDER BY d.rang");
$CityList = array();
while ($_sql = mysql_fetch_assoc($sql)) {
$CityList[$_sql['id']] = $_sql['header'];
}
if ($Fcity && $Fcity != 0)
$where.=" and d.id=" . $Fcity . "";
elseif ($_POST['city'] && $class->_dig($_POST['city']) > 0)
$where.=" and d.id=" . $class->_dig($_POST['city']) . "";
if ($CitySearch != 0)
$where.=" and wd.city=" . $CitySearch . " ";
$sql = mysql_query("SELECT w.header, w.direction, w.subheader, wd.colsmonth, wd.is_new, wd.public_date_finish, wd.p_date_finish, w.aliaslink, wd.aliaslink as wd_aliaslink, w.direction, wd.city, wd.date_start, d.header as city_name, wd.date_end, wd.cid, wd.id as wd_id, w.id as w_id FROM " . $class->_cfg['pfx'] . "workshops as w
LEFT JOIN " . $class->_cfg['pfx'] . "workshops_date as wd ON wd.cid=w.id
LEFT JOIN " . $class->_cfg['pfx'] . "dictionary as d ON d.id=wd.city
WHERE w.public='1' and wd.public='1' and wd.date_end>='" . date("Y-m-d") . "' and w.direction<>'' and wd.predprosomtr='0' " . $where . " ORDER BY wd.date_start, wd.city");
//$output.=$where;
$month = 12;
$year = date("Y");
while ($_sql = mysql_fetch_assoc($sql)) {
$view = true;
if ($_sql['public_date_finish'] == '1' && $_sql['p_date_finish'] < date("Y-m-d"))
$view = false;
if ($view) {
$arWorkshops[$_sql['w_id']] = $_sql;
if (!isset($arWorkshopsCity[$_sql['cid']][$_sql['city']]) && $_sql['city'] > 0)
$arWorkshopsCity[$_sql['cid']][$_sql['city']] = $_sql['city'];
if (isset($arWorkshopsDate[$_sql['cid']]['count']))
$arWorkshopsDate[$_sql['cid']]['count'] = $arWorkshopsDate[$_sql['cid']]['count'] + 1;
else
$arWorkshopsDate[$_sql['cid']]['count'] = 1;
$direct = explode('#', $_sql['direction']);
for ($i = 0; $i < count($direct); $i++) {
if (trim($direct[$i]) != '') {
$arDirectionList[$direct[$i]] = $direct[$i];
}
}
//$arDirectionList[$_sql['direction']]=$_sql['direction'];
if (!isset($arWorkshopsDate[$_sql['cid']][ceil($class->convert_date($_sql['date_start'], '.', "month"))]))
$arWorkshopsDate[$_sql['cid']][ceil($class->convert_date($_sql['date_start'], '.', "month"))] = $_sql;
if ($class->convert_date($_sql['date_start'], '.', "month") < $month && $class->convert_date($_sql['date_start'], '.', "year") == $year) {
$month = $class->convert_date($_sql['date_start'], '.', "month");
$year = $class->convert_date($_sql['date_start'], '.', "year");
}
//if($class->convert_date($_sql['date_start'], '.', "year")==(date("Y")+1))$year=$class->convert_date($_sql['date_start'], '.', "year");
//$output.=$_sql['header']."-".$_sql['date_start']."-".$_sql['wd_id']."<br>";
}
}
//var_dump($arWorkshopsDate[185]);
$output.='<table class="table"><tr><th width="60"> </th><th class="first" style="width:auto">Название</th>';
if ($_MONTH == 12)
$w = "5%"; else
$w = "9%";
for ($i = $month; $i < ($month + $_MONTH); $i++) {
if ($year == date("Y"))
$m = $i;else
$m++;
if ($m <= 12 && $year == date("Y")) {
$output.='<th class="month" style="width:' . $w . '">' . $class->convert_date($m, '.', "myear") . ' <span>' . $year . '</span></th>';
} else {
if ($m > 12) {
$m = 1;
$year = $year + 1;
}
$output.='<th class="month" style="width:' . $w . '">' . $class->convert_date($m, '.', "myear") . ' <span>' . $year . '</span></th>';
}
}
$output.=' <th style="width:10%">';
if ($typeblock == 'webinars')
$output.='Формат';
else
$output.='Город';
$output.='</th></tr>';
if (isset($arWorkshops)) {
//foreach($arWorkshops as $LO=>$listOrd){
foreach ($arWorkshops as $k => $value) {
if (!$direction || $direction == 0)
$direction2 = $class->_direction($value['direction']);
else
$direction2 = $direction;
foreach ($arWorkshopsCity[$k] as $LO => $listOrd) {
$output2 = "";
$link_date = "";
$pt = 0;
$m_nth = ceil($month);
$is_new_class = '';
for ($i = ceil($month); $i < ($month + $_MONTH); $i++) {
if ($m_nth > 12)
$m_nth = 1;
if (isset($arWorkshopsDate[$k][$m_nth]) && $arWorkshopsDate[$k][$m_nth]['city'] == $LO) {
$pt++;
if ($pt == 1)
$city_name = $arWorkshopsDate[$k][$m_nth]['city_name'];
//if(isset($_TYPE) && $_TYPE!=0)$output.='<td class="date"><a href="/'.$typeblock.'/'.$value['aliaslink'].'/'.$arWorkshopsDate[$k][$i]['wd_aliaslink'].'/">';
//else
if (($arWorkshopsDate[$k][$m_nth]['is_new'] == '1') || ($arWorkshopsDate[$k][$m_nth + 1]['is_new'] == '1')) {
$is_new_class = " it_is_new";
} else {
$is_new_class = '';
}
$output2.='<td class="date"><a href="/' . $typeblock . '/' . $arDictionaryID[$direction2]['aliaslink'] . '/' . $value['aliaslink'] . '/' . $arWorkshopsDate[$k][$m_nth]['wd_aliaslink'] . '/">';
$link_date = '/' . $typeblock . '/' . $arDictionaryID[$direction2]['aliaslink'] . '/' . $value['aliaslink'] . '/' . $arWorkshopsDate[$k][$m_nth]['wd_aliaslink'] . '/';
if ($arWorkshopsDate[$k][$m_nth]['colsmonth'] > 0)
$output2.=$class->convert_date($arWorkshopsDate[$k][$m_nth]['date_start'], '.', "day_month") . "</a><br />" . $arWorkshopsDate[$k][$m_nth]['colsmonth'] . " мес.";
elseif ($arWorkshopsDate[$k][$m_nth]['date_start'] == $arWorkshopsDate[$k][$m_nth]['date_end'])
$output2.=$class->convert_date($arWorkshopsDate[$k][$m_nth]['date_start'], '.', "day_month") . "</a>";
else
$output2.=$class->convert_date($arWorkshopsDate[$k][$m_nth]['date_start'], '.', "day_month") . "<br />-" . $class->convert_date($arWorkshopsDate[$k][$m_nth]['date_end'], '.', "day_month") . "</a>";
$output2.='</td>';
}else {
$output2.='<td></td>';
}
$m_nth++;
}
if (($arWorkshopsDate[$k][$m_nth]['is_new'] == '1')) {
$is_new_class = " it_is_new";
}
$output.='<tr><td class="' . $is_new_class . '"> </td><td>';
//if(isset($_TYPE) && $_TYPE!=0)$output.='<strong>'.$value['header'].'</strong>';
//else
if ($pt == 1 && $arWorkshopsDate[$k]['count'] == 1)
$link = $link_date;
else
$link = '/' . $typeblock . '/' . $arDictionaryID[$direction2]['aliaslink'] . '/' . $value['aliaslink'] . '/';
$output.='<a href="' . $link . '"><strong>' . $value['header'] . '</strong>';
if (trim($value['subheader']) != '')
$output.=': ' . $value['subheader'] . '';
$output.='</a>';
$output.='</td>';
$output.=$output2;
$output.=' <td class="city">' . $city_name . '</td></tr>';
}
}
//}
}
$output.='</table>';
?>
Issue solved. By default some "good" coder made it show only from 12th month in $month = 12;
I just changed it to $month = date("m"); And this solved my issue

Categories