Hi i am creating a php calendar i have a Problem in that

Posted by udaya on Stack Overflow See other posts from Stack Overflow or by udaya
Published on 2010-04-20T04:25:00Z Indexed on 2010/04/20 4:33 UTC
Read the original article Hit count: 178

Filed under:
|

Hi i am creating a calendar i which i filled the year and date like this <<<<< Year >>>>>> <<<<< month >>>>>> by clicking on the arrow marks the year and month can be increased and decreased now i have to fill the dates for the year and month selected I calculated the first day of month and last date of the month The dates must be start filling from the first day Say if the first day is thursday the date 1 must be on thursday and the next days must follow that till the last date These are my functions in my controller "

function phpcal()
    {
        $month=04;
        $day=01;
        $year=2010;
        echo date("D", mktime(0,0,0,$month,$day,$year)); //here i am calculating the first day of the month
        echo '<br>lastdate'.date("t", strtotime($year . "-" . $month . "-01"));'' here i am calculating the lasdt date of the month
        //echo '<br>'.$date_end  = $this->lastOfMonth();
        $this->load->view('phpcal');
    }
function firstOfMonth($m1,$y1) 
{ 
           return date("m/d/Y", strtotime($m1.'/01/'.$y1.' 00:00:00')); 
} 
function lastOfMonth() 
{ 
           return date("m/d/Y", strtotime('-1 second',strtotime('+1                                                                month',strtotime(date('m').'/01/'.date('Y').' 00:00:00')))); 
}
function phpcalview()
    {
        $year = $this->input->post('yearvv');
        $data['year'] = $this->adminmodel->selectyear();
        $data['date'] = $this->adminmodel->selectmonth();
        //print_r($data['date'] );

        $this->load->view('phpcal',$data); 
    }

This is my view page

<table cellpadding="2" cellspacing="0" border="1" bgcolor="#CCFFCC" align="center"  class="table_Style_Border">
<?  if(isset($date))
{
foreach($date as $row)
{?>


<tr>
    <td><?= $row['dbDate1'];?></td> <td><?= $row['dbDate2'];?></td> <td><?= $row['dbDate3'];?></td> <td><?= $row['dbDate4'];?></td>     <td><?= $row['dbDate5'];?></td> <td><?= $row['dbDate6'];?></td> <td><?= $row['dbDate7'];?></td>
</tr>
<tr bgcolor="#FFFFFF">
    <td><?= $row['dbDate8'];?></td> <td><?= $row['dbDate9'];?></td> <td><?= $row['dbDate10'];?></td> <td><?= $row['dbDate11'];?></td> <td><?= $row['dbDate12'];?></td> <td><?= $row['dbDate13'];?></td> <td><?= $row['dbDate14'];?></td>
</tr>
<tr>
    <td><?= $row['dbDate15'];?></td> <td><?= $row['dbDate16'];?></td> <td><?= $row['dbDate17'];?></td> <td><?= $row['dbDate18'];?></td> <td><?= $row['dbDate19'];?></td> <td><?= $row['dbDate20'];?></td> <td><?= $row['dbDate21'];?></td>
</tr>
<tr bgcolor="#FFFFFF">
    <td><?= $row['dbDate22'];?></td> <td><?= $row['dbDate23'];?></td> <td><?= $row['dbDate24'];?></td> <td><?= $row['dbDate25'];?></td> <td><?= $row['dbDate26'];?></td> <td><?= $row['dbDate27'];?></td> <td><?= $row['dbDate28'];?></td>
</tr>
<tr>
    <td><?= $row['dbDate29'];?></td> <td><?= $row['dbDate30'];?></td> <td><?= $row['dbDate31'];?></td> <td><?= $row['dbDate1'];?></td> <td><?= $row['dbDate1'];?></td> <td><?= $row['dbDate1'];?></td> <td><?= $row['dbDate1'];?></td>
</tr>

</tr>
<? }} ?>
</table>

How can i insert the dates starting from the day i have calculated in the function phpcal

© Stack Overflow or respective owner

Related posts about php

Related posts about codeigniter