SOLVED::I WANT TO DISPLAY THE COURSE NAME - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: SOLVED::I WANT TO DISPLAY THE COURSE NAME (/showthread.php?tid=42095) |
SOLVED::I WANT TO DISPLAY THE COURSE NAME - El Forum - 05-26-2011 [eluser]charlesmudy[/eluser] Hi, I'm new to CodeIgniter. My question is, I would like to view the name of my course_id which is in another table but it simply gives me the details from that table. I have a table called student which has the ID of the courses table, so when I select the row from the student table..it gives me ofcourse the row id but I want the course name to be displayed. My code: <?php echo "Status: " . " " . $row->status_id; ?><br /> <?php echo "Course: " . " " . $row->course_id; ?><br /> <?php echo "Nationality: " . " " . $row->nationality_id; ?> My display:Attached Thanks in advance. Charles SOLVED::I WANT TO DISPLAY THE COURSE NAME - El Forum - 05-26-2011 [eluser]ηυмвєяσηє[/eluser] please fix the title, Its so ugly. About your problem, you should change your sql query. Something like this : $query = "SELECT student.first_name, student.last_name, student.status_id, student.nationality_id, courses.name FROM student, courses WHERE student.course_id = courses.id"; SOLVED::I WANT TO DISPLAY THE COURSE NAME - El Forum - 05-26-2011 [eluser]InsiteFX[/eluser] I guess that when you clicked on FAST REPLY you did not read the BIG RED LETTERS! InsiteFX SOLVED::I WANT TO DISPLAY THE COURSE NAME - El Forum - 05-26-2011 [eluser]dUspan[/eluser] yes try using LEFT JOIN.it will helps you display what you need. Code: $this->query("SELECT * FROM table1 LEFT JOIN table1 ON table1.id = table2.id where id = ?"); i just the used (*) for example purposed only.its much better when you select only the row you want to display. i hope it helps SOLVED::I WANT TO DISPLAY THE COURSE NAME - El Forum - 05-26-2011 [eluser]charlesmudy[/eluser] [quote author="ηυмвєяσηє" date="1306416823"]please fix the title, Its so ugly. About your problem, you should change your sql query. Something like this : Code: $q = "SELECT student.first_name, student.last_name, student.status_id, student.nationality_id, courses.name FROM student, courses WHERE student.course_id = courses.id" I tried it but still not working. My controller: Quote:public function get_student() My view: Quote:<?php echo "Course: " . " " . $row->course_id; ?><br /> Error message: Quote:Personal Data Information for John SOLVED::I WANT TO DISPLAY THE COURSE NAME - El Forum - 05-26-2011 [eluser]charlesmudy[/eluser] [quote author="ηυмвєяσηє" date="1306416823"]please fix the title, Its so ugly. About your problem, you should change your sql query. Something like this : $query = "SELECT student.first_name, student.last_name, student.status_id, student.nationality_id, courses.name FROM student, courses WHERE student.course_id = courses.id";[/quote] Ohh sorry I didnt change the course_id ...to course_name Now I got it...thank you so much after 2 nights of sweat woooooooooooooooooooooooooo..now I get Quote:Personal Data Information for John |