₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,326,126 members, 8,425,083 topics. Date: Friday, 12 June 2026 at 05:54 AM

Toggle theme

Help Fix A Codeigniter Blog Issue - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHelp Fix A Codeigniter Blog Issue (1146 Views)

1 Reply (Go Down)

Help Fix A Codeigniter Blog Issue by CALEB65(op):
Hello geeks,

I have been creating a blog using codeigniter and am almost through with the back end.
I have created separate tables in my database to music file info, uploaded video file info and blog posts.
I want to get this information from these 3 tables and display them on the homepage whenever an update to the database is made and I am confused on how to go about it.
please help me with suggestions on what to do. thanks
dhtml18
DanielTheGeek
seunthomas
fincoapp
anybody please
Re: Help Fix A Codeigniter Blog Issue by webdeveloperqx: 11:47pm On Oct 27, 2016
1. create your views,

2. create your models ( CRUD) ,

3. create a controller to handle the interaction between your views and the models. ( create the method to handle the update, you can also do an ajax call to a file to get updated models(data) from the database and use a view to render it.

I did not provide code samples, i believe you okay coding with codeigniter, those are the steps to follow.

i hope this helps.
Re: Help Fix A Codeigniter Blog Issue by CALEB65(op): 6:09am On Oct 28, 2016
webdeveloperqx:
1. create your views,

2. create your models ( CRUD) ,

3. create a controller to handle the interaction between your views and the models. ( create the method to handle the update, you can also do an ajax call to a file to get updated models(data) from the database and use a view to render it.

I did not provide code samples, i believe you okay coding with codeigniter, those are the steps to follow.

i hope this helps.
how do I get the data from the three tables and merge the into 1 page
like get all the data and display them on the homepage?
Re: Help Fix A Codeigniter Blog Issue by larisoft:
first get the data from the database and pass it to the home view.
to keep it simple, I didnt use models

In your home controller, create or edit the index function to look like so

function index(){

//get 10 music info
$this->db->limit(0, 10);
$music = $this->db->get("music_info" )->result_array(); //music info is name of table

//get 10 video info
$this->db->limit(10, 0);
$vids = $this->db->get("video_info" )->result_array(); //video info is name of table

//get 10
$this->db->limit(10, 0);
$posts = $this->db->get("posts" )->result_array(); //posts is name of table


$data['music'] = $music;
$data['videos'] = $vids;
$data['posts'] = $posts;

$this->load->view("index", $data);

}


Now in your views, create index.php and in it you can output music like this

<h1> Music Tracks </h1>
<ol>
<?php foreach($music as $m){ ?>

<li> <?php echo $m['title'];?> <!--Note that title is the name of a column in the music_info table --> </li>

<?php}?>
</ol>


Do same for videos and posts on the same index page. Just place each in the section of the html you will want it to appear.


let me know if you meet any errors. Just wrote this here and didnt test it.
Re: Help Fix A Codeigniter Blog Issue by Kofacts(m): 8:47pm On Oct 30, 2016
guess larisoft already answered your question. But just in case you can always ask for emphasis.
Happy Coding..
1 Reply

Having Codeigniter Issues Or Want To Learn? Contact A Codeigniter GuruI Need Volunteers To Implement A Codeigniter Based Platform For NigeriansHelp Fix This Android Studio Error Dhtml18 And Otherd234

Can Anybody Recommend An E-learning Worpress PluginShared How To Create A Working Cheat On All NetworkWhat To Do After You Are Hacked