Welcome Guest, Not a member yet? Register   Sign In
problem in printing month of date
#1

[eluser]Unknown[/eluser]
model
Code:
function articledate()
    {
        //$this->db->distinct();
        //$this->db->order_by("id", "desc");
        $result_selected = $this->db->query("SELECT DISTINCT MONTH(articledate) FROM articles");
        return $result_selected->result();
    }
view

Code:
<?php
   foreach($articled as $row)
{
?>
<php echo $row->articledate?&gt;
&lt;?php } ?&gt;

controller
Code:
$this->data['articled'] = $this->Home_model->articledate();
this code is running well and iam getting result in controller

but i dont know how to print the result in view

can anyone help me???
thanks in advance.....
#2

[eluser]jmadsen[/eluser]
You will need to use a column alias for your field, and then do your $row->articledate using the alias name

so:

Code:
SELECT DISTINCT MONTH(articledate) AS articledate FROM articles
#3

[eluser]Anonymous[/eluser]
First hit on google:

Code:
function ConvertDate($sql_date) {
  $date=strtotime($sql_date);
  $final_date=date("F j, Y, g:i a", $date);
  return $final_date;
}

try to make a helper with this function
#4

[eluser]jmadsen[/eluser]
his query was fine - might as well do it on the db like he is and bring back less data. he just needed to know how to access computed fields.
#5

[eluser]Unknown[/eluser]
now my code running fine
and i am getting results like this
july 2011
june 2011
...

now i want to convert july 2011
into 72011
and june 2011 to 62011

can anyone help me?
thanks in advance......
#6

[eluser]jmadsen[/eluser]
How can you be getting "Month Year" if you are only asking for MONTH in your query?

"SELECT DISTINCT MONTH(articledate)"

Have a look at this, and read your Manual about in Mysql & Php

http://ellislab.com/forums/viewthread/191776/




Theme © iAndrew 2016 - Forum software by © MyBB