How to retrieve data with php calendar

ساخت وبلاگ

Vote count: 0

I'm using phalcon-2.0.1. I just create a calendar for my blog archive. i want to retrieve data from database which is matched with the date. my code retrieve only one post. I'm not understanding how to query loop through to check the date related data. I need to retrieve that posts which is related with the date users clicked.

[controller]

public function archivesAction($date)
{ $description = "blog-Archive-List"; $this->view->setVar("dynadesc", $description); $keywords = "blog-key"; $this->view->setVar("dynakey", $keywords); if($this->session->has('uname')) { $uid = $this->session->get('id'); $name = $this->session->get('uname'); $active = $this->session->get('active'); $level = $this->session->get('level'); } $this->view->setVar('uid', $uid); $this->view->setVar("uname", $name); $this->view->setVar("active", $active); $this->view->setVar("level", $level); $get = Blogs::find(); foreach($get as $d) { $times = explode(' ', $d->datetime); $dater = $times[0]; $timer = $times[1]; } $archs = Blogs::find(["datetime LIKE :key:","bind"=>["key"=>'%'.$dater.'%']]); $this->view->setvar('dates', $archs); $this->view->pick('blog/archive');
} 

[Calendar in blog page]

<table>
<tr>
<th class='L'><a href="blog?month=<?php echo($prev_month.'&amp;year='.$prev_year);?>">&lsaquo;</a></th>
<th colspan="5" class="monyer"><?php echo($monthName.'-'.$year); ?></th>
<th class='R'><a href="blog?month=<?php echo($next_month); ?>&amp;year=<?php echo($next_year);?>">&rsaquo;</a></th>
</tr>
<tr class='caption'>
<td>S</td>
<td>M</td>
<td>T</td>
<td>W</td>
<td>T</td>
<td>F</td>
<td>S</td>
</tr>
<?php
$monthstart = date("w", $timestamp);
$lastday = date("d", mktime (0, 0, 0, $month + 1, 0, $year));
$startdate = -$monthstart;
$numrows = ceil (((date("t",mktime (0, 0, 0, $month + 1, 0, $year))
+ $monthstart) / 7));
for ($k = 1; $k <= $numrows; $k++){
?><tr class="days"><?php
for ($i = 0; $i < 7; $i++){
$startdate++;
if (($startdate <= 0) || ($startdate > $lastday)){
//If we have a blank day in the calendar.
?><td class="L"><?php echo('&nbsp;');?></td><?php
} else {
if ($startdate == date("j") && $month == date("n") && $year == date("Y")){?>
<td class="today"><a href="blog/archives?date=<?php echo($year.'-'.$month.'-'.$startdate); ?>"><?php echo($startdate); ?></a></td><?php
} else {
?><td><a href="blog/archives/<?php echo($year.'-'.$month.'-'.$startdate); ?>"><?php echo($startdate); ?></a></td><?php } } } ?>
</tr><?php } ?>
</table> 

[View - archive.volt]

{% for archs in dates %}
<a href="blog/showfull/<?php echo($archs->id); ?>"> <dl class="archL"> <dt><b>{{archs.btitle}}</b><br/><em>{{archs.datetime}}</em></dt> <dd>{{archs.bintro}}</dd> </dl>
</a>
{% endfor %}
asked 1 min ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 356 تاريخ : پنجشنبه 31 تير 1395 ساعت: 12:55