Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Course Queries Competitions/Entrance Exams 2 years ago
Posted on 16 Aug 2022, this text provides information on Competitions/Entrance Exams related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
controller: Test.php
php defined('BASEPATH') OR exit('No direct script access allowed'); class Test extends CI_Controller { function __construct() { parent :: __construct(); $this->load->helper(array('form', 'url')); $this->load->model('Fetch_data'); } public function agriculture_exam() { $stream = 'agriculture'; $data['exam'] = $this->Fetch_data->top_agriculture_exams($stream); $this->load->view('header',$data); } }
view: header.php
class="list"> php foreach($exam as $row) { echo "".$row['exam_name'].""; } ?>
model: Fetch_data.php
php class Fetch_data extends CI_Model { function __construct() { parent::__construct(); } public function top_agriculture_exams($stream) { $this->db->select('exam_name'); $this->db->from('all_exams_details'); $this->db->where('field',$stream); $this->db->order_by('exam_name'); $this->db->limit('10'); $query = $this->db->get(); $result = $query->result_array(); return $result; } }
I am new in ci. In controller i.e. Test.php I am defining $stream='agriculture' and pass $stream variable to top_agriculture_exams model. Now, when I am fetching data on header.php file it show me a Message: Undefine variable: $exam I don't know why. So, how can I fix it ?please help me.
Thank You
Please check my below code. This will help you.
class="list"> php if ($exam !== NULL): foreach ($exam as $row): echo "" . $row['exam_name'] . ""; endforeach; endif; ?>
Also cna you please put this code in View and share result.
php var_dump($exam); ?>
Also check your model code below.
php class Fetch_data extends CI_Model { function __construct() { parent::__construct(); } public function top_agriculture_exams($stream) { $this->db->select('exam_name'); $this->db->from('all_exams_details'); $this->db->where('exam_name',$stream); $this->db->order_by('exam_name'); $this->db->limit('10'); $query = $this->db->get(); $result = $query->result_array(); return $result; } }
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
Course Queries 4 Answers
Course Queries 5 Answers
Course Queries 1 Answers
Course Queries 3 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.