• <small id='JvJyo'></small><noframes id='JvJyo'>

    <tfoot id='JvJyo'></tfoot>
    <i id='JvJyo'><tr id='JvJyo'><dt id='JvJyo'><q id='JvJyo'><span id='JvJyo'><b id='JvJyo'><form id='JvJyo'><ins id='JvJyo'></ins><ul id='JvJyo'></ul><sub id='JvJyo'></sub></form><legend id='JvJyo'></legend><bdo id='JvJyo'><pre id='JvJyo'><center id='JvJyo'></center></pre></bdo></b><th id='JvJyo'></th></span></q></dt></tr></i><div id='JvJyo'><tfoot id='JvJyo'></tfoot><dl id='JvJyo'><fieldset id='JvJyo'></fieldset></dl></div>
      <bdo id='JvJyo'></bdo><ul id='JvJyo'></ul>

        <legend id='JvJyo'><style id='JvJyo'><dir id='JvJyo'><q id='JvJyo'></q></dir></style></legend>

        使用 PHP foreach 代码填充日历

        Populating a calendar with PHP foreach code(使用 PHP foreach 代码填充日历)

          1. <small id='5ZgeS'></small><noframes id='5ZgeS'>

            <tfoot id='5ZgeS'></tfoot>

                <bdo id='5ZgeS'></bdo><ul id='5ZgeS'></ul>

                • <i id='5ZgeS'><tr id='5ZgeS'><dt id='5ZgeS'><q id='5ZgeS'><span id='5ZgeS'><b id='5ZgeS'><form id='5ZgeS'><ins id='5ZgeS'></ins><ul id='5ZgeS'></ul><sub id='5ZgeS'></sub></form><legend id='5ZgeS'></legend><bdo id='5ZgeS'><pre id='5ZgeS'><center id='5ZgeS'></center></pre></bdo></b><th id='5ZgeS'></th></span></q></dt></tr></i><div id='5ZgeS'><tfoot id='5ZgeS'></tfoot><dl id='5ZgeS'><fieldset id='5ZgeS'></fieldset></dl></div>
                    <tbody id='5ZgeS'></tbody>

                  <legend id='5ZgeS'><style id='5ZgeS'><dir id='5ZgeS'><q id='5ZgeS'></q></dir></style></legend>
                  本文介绍了使用 PHP foreach 代码填充日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用以下 jQuery 日历:https://github.com/MrHus/jquery-monthly-ical/tree/

                  I am using the following jQuery calendar: https://github.com/MrHus/jquery-monthly-ical/tree/

                  按照文档,它告诉我应该像这样输入日期:

                  Following the documentation, it tells me that dates should be entered like this:

                  eventdates: [{"date": "2009-03-21", "title": "My birthday", "desc": "Its my birthday!"},
                               {"date": "yyyy-01-01", "title": "New Year", "desc": "Its a new year!"},
                               {"date": "2009-mm-01", "title": "New Month", "desc": "First day of the new month!"},
                               {"date": "2010-mm-01", "title": "New Month", "desc": "First day of the new month!"},
                               {"date": "2010-09-01", "title": "Convention", "desc": "September convention."}, 
                               {"date": "2010-09-02", "title": "Convention", "desc": "September convention day two."}, 
                               {"date": "2010-mm-01", "title": "Towl", "desc": "Dont forget to bring a towl."}    
                              ] 
                  

                  但是,我想使用 foreach 语句用 PHP 变量填充上述数组.我有这个,但是它不起作用,没有错误,没有警告,但是没有显示该事件:

                  However, I'd like to populate the above arrays with PHP variables, with a foreach statement. I've got this, however it doesn't work, no errors, no warnings, but the event is not displayed:

                          <?php
                          foreach($events as $event)
                          {
                          ?>
                              eventdates: [{"date": "<?php date('Y/m/d') ?>", "title": "<?php $event->title ?>", "desc": "<a href="<?php  echo SITE_URL ?>/index.php/events/get_event?id=<?php $event->id ?>">Details/Signups</a>"},]
                          <?php
                          }
                          ?>
                  

                  这是之前在日历之外的代码,在我的表格中,它可以工作:

                  This is the previous code outside of calendar, and inside a table I had, and it works:

                  <?php
                  if(!$events)
                  {
                      echo 'No Upcoming Events';
                  }
                  else
                  {
                      ?>
                  <center>
                      <table border="1px" width="80%">
                          <tr>
                              <td width="25%"><b>Date:</b></td>
                              <td width="60%"><b>Event:</b></td>
                              <td><b>Details/Signups</b></td>
                          </tr>
                              <?php
                              foreach($events as $event)
                              {
                                  if($event->active == '2')
                                  {
                                      continue;
                                  }
                          echo '<tr><td>'.date('n/j/Y', strtotime($event->date)).'</td>';
                          echo '<td>'.$event->title.'</td>';
                          echo '<td><a href="'.SITE_URL.'/index.php/events/get_event?id='.$event->id.'">Details/Signups</a></td></tr>';
                      }
                      ?>
                      </table>
                  </center>
                      <?php
                  }
                  ?>
                  

                  代码位于 .tpl 文件中,通过 .class.php 文件显示.在其中,是运行必要变量的所有查询.

                  The code is inside a .tpl file, which is shown via .class.php file. Inside of it, are all of the queries to run necessary variables.

                  推荐答案

                  应该这样做:

                  $dates = array();
                  
                  // build an array with that data
                  foreach($events as $event)
                    $dates[] = (object)array(
                       'date'  => date('Y/m/d'),
                       'title' => $event->title,
                       'desc'  => sprintf('<a href="%s/index.php/events/get_event?id=%s">Details/Signups</a>', SITE_URL, $event->id),
                    );
                  
                  ?>
                  
                  eventdates:
                  
                  <?php print json_encode($dates); // print it as a json string ?>
                  

                  这篇关于使用 PHP foreach 代码填充日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                          <tbody id='EAUjW'></tbody>

                        • <tfoot id='EAUjW'></tfoot>
                            <bdo id='EAUjW'></bdo><ul id='EAUjW'></ul>

                            <small id='EAUjW'></small><noframes id='EAUjW'>

                          • <i id='EAUjW'><tr id='EAUjW'><dt id='EAUjW'><q id='EAUjW'><span id='EAUjW'><b id='EAUjW'><form id='EAUjW'><ins id='EAUjW'></ins><ul id='EAUjW'></ul><sub id='EAUjW'></sub></form><legend id='EAUjW'></legend><bdo id='EAUjW'><pre id='EAUjW'><center id='EAUjW'></center></pre></bdo></b><th id='EAUjW'></th></span></q></dt></tr></i><div id='EAUjW'><tfoot id='EAUjW'></tfoot><dl id='EAUjW'><fieldset id='EAUjW'></fieldset></dl></div>
                          • <legend id='EAUjW'><style id='EAUjW'><dir id='EAUjW'><q id='EAUjW'></q></dir></style></legend>