How can I do this with CodeIgniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How can I do this with CodeIgniter (/showthread.php?tid=55186) |
How can I do this with CodeIgniter - El Forum - 10-13-2012 [eluser]Marcus Marden[/eluser] Code: $SQL1 = mysql_query("SELECT id, name FROM categories ORDER BY name ASC"); Showing like that: Code: News Thank you for advice. How can I do this with CodeIgniter - El Forum - 10-13-2012 [eluser]CroNiX[/eluser] Try the tutorials and the user guide. There are several examples on how to do these basic CI things. How can I do this with CodeIgniter - El Forum - 10-13-2012 [eluser]rip_pit[/eluser] you can have a look there for every DB querying methods : http://www.codeigniter.fr/user_guide/database/active_record.html You can use a ->join to query multiple tables using one unique query. then use a simple foreach to filter the results and separate the cat. Something like : Code: $this->db->select('blog.*, categories.id, categories.name'); How can I do this with CodeIgniter - El Forum - 10-14-2012 [eluser]Marcus Marden[/eluser] @CroNiX, this is not a basic question! very simple if you know CI well... @rip_pit, thank for codes but it doesn't show category name, it is only get results from blog and category tables. I want to do more different job. Thanks anyway. How can I do this with CodeIgniter - El Forum - 10-14-2012 [eluser]egy_programozo[/eluser] rip_pit's code v1.2 Code: $this->db->select('blog.*, categories.id as category_id, categories.name as categories_name'); |