Get Other data in Views |
[eluser]MisaghCJ[/eluser]
Hi to all. I have been working with codeigniter since 2 months ago and during this period I had a problem that I didn't find any solution for it. Imagine we have a monthly archive for news and we want to show it this way: January 2011 => List of News August 2011 => List of News September 2011 => List of News The news table has "month" field that stores the month of news. I get list of month by "group by" in sql and when I want to show list of news I can't do that. Consider we want to show this 3 months in view and we draw a table for each of them. the title of table is the name of Month and the rows of table is list of last five news. How can we show it in the view? I don't know how can I send data for view. This Picture shows my words better : http://www.img4up.com/up2/31162532966910755015.gif Thanks
[eluser]John_Betong_002[/eluser]
[quote author="MisaghCJ" date="1307502640"] anyone can help? [/quote] Please supply the table structure and exact output requirements.
[eluser]MisaghCJ[/eluser]
name of table : news columns of table : news_id , title , body , month , year Insert News : Code: $this->db->set('title', $title); and we want to show the list of months : Code: $this->db->group_by('month'); and we show the list of months in view : Code: foreach($news as $value) { and my problem is here : How can I show the list of last 3 news of every month, blow that month. Like this picture : http://www.img4up.com/up2/31162532966910755015.gif --------------------------------------------------------------------------- my current code is like this : Code: <div class="textarea"> But I don't want to use news model in view directly. I want to send all data from controller.
[eluser]InsiteFX[/eluser]
Code: $data = array( InsiteFX
[eluser]MisaghCJ[/eluser]
Dear InsiteFX, That was example! my problem is another thing. anyway thanks for your point.
[eluser]John_Betong_002[/eluser]
The date setting creates problems when trying to do anything constructive. It is far better to save the date as a MYSQL->TimeStamp; Check this out - complete with source code: http://johns-jokes.com/misaghcj |
Welcome Guest, Not a member yet? Register Sign In |