日期选择器 - 从数据库加载预订日期并设置特定日期数组

发布于 2025-01-04 22:18:22 字数 1779 浏览 2 评论 0原文

我需要一些帮助 - 我尝试设置 setSpecificDate 以便我从数据库获取(并已格式化)的数组能够正确加载。当我打印 $dates_booked 时,格式是 100% 正确的“yyyy-mm-dd” - 任何帮助/建议将不胜感激。

有关日期选择器/相关代码的更多信息:http://www.triconsole.com/php/calendar_datepicker。预先

感谢!

我的代码:

    $datesArray = Array();
                        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                        $datesArray[] =  $row['reserved_date'];  
                        $dates_booked=implode(",",$datesArray); 
                        $arrtrans = array();
                        $arrtrans[","] = '"'.",".'"';
                        $dates_booked = strtr($dates_booked,$arrtrans);
                        $dates_booked= '"'.$dates_booked.'"';
                        } 
                          $myCalendar = new tc_calendar("date5", true, false);
                          $myCalendar->setIcon("calendar/images/iconCalendar.gif");
                          $myCalendar->setDate(date('d'), date('m'), date('Y'));
                          $myCalendar->setPath("calendar/");
                          $myCalendar->setYearInterval(2012, 2020);
                          $myCalendar->dateAllow(date("Y-m-d"), '2020-01-01');
                          $myCalendar->setDateFormat('j F Y');
                          //$myCalendar->setHeight(350);
                         // $myCalendar->autoSubmit(true, "form1");
                          $myCalendar->setAlignment('left', 'bottom');    
                          // Problematic Line

$myCalendar->setSpecificDate(array('.$dates_booked.'
                          ), 0, '');
                          $myCalendar->writeScript(); 

I need some help - I have tried setting setSpecificDate so that the array I fetch (and have formatted) from the db will load correctly. When I print $dates_booked the format is 100% correct "yyyy-mm-dd" - any help / advice will be appreciated.

More info about the datepicker / associated code : http://www.triconsole.com/php/calendar_datepicker.php

Thanks in advance!

My Code:

    $datesArray = Array();
                        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                        $datesArray[] =  $row['reserved_date'];  
                        $dates_booked=implode(",",$datesArray); 
                        $arrtrans = array();
                        $arrtrans[","] = '"'.",".'"';
                        $dates_booked = strtr($dates_booked,$arrtrans);
                        $dates_booked= '"'.$dates_booked.'"';
                        } 
                          $myCalendar = new tc_calendar("date5", true, false);
                          $myCalendar->setIcon("calendar/images/iconCalendar.gif");
                          $myCalendar->setDate(date('d'), date('m'), date('Y'));
                          $myCalendar->setPath("calendar/");
                          $myCalendar->setYearInterval(2012, 2020);
                          $myCalendar->dateAllow(date("Y-m-d"), '2020-01-01');
                          $myCalendar->setDateFormat('j F Y');
                          //$myCalendar->setHeight(350);
                         // $myCalendar->autoSubmit(true, "form1");
                          $myCalendar->setAlignment('left', 'bottom');    
                          // Problematic Line

$myCalendar->setSpecificDate(array('.$dates_booked.'
                          ), 0, '');
                          $myCalendar->writeScript(); 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江湖正好 2025-01-11 22:18:22

这个烂摊子:

                    $datesArray[] =  $row['reserved_date'];  
                    $dates_booked=implode(",",$datesArray); 
                    $arrtrans = array();
                    $arrtrans[","] = '"'.",".'"';
                    $dates_booked = strtr($dates_booked,$arrtrans);
                    $dates_booked= '"'.$dates_booked.'"';

完全没用。你只需要这个:

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $datesArray[] =  $row['reserved_date'];  
}
/* ... */
$myCalendar->setSpecificDate($datesArray);

This mess:

                    $datesArray[] =  $row['reserved_date'];  
                    $dates_booked=implode(",",$datesArray); 
                    $arrtrans = array();
                    $arrtrans[","] = '"'.",".'"';
                    $dates_booked = strtr($dates_booked,$arrtrans);
                    $dates_booked= '"'.$dates_booked.'"';

is totally useless. Yuo need only this:

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $datesArray[] =  $row['reserved_date'];  
}
/* ... */
$myCalendar->setSpecificDate($datesArray);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文