How to do this? - 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 to do this? (/showthread.php?tid=53503) Pages:
1
2
|
How to do this? - El Forum - 07-26-2012 [eluser]Mahn[/eluser] Ahoy, I'm currently trying to make a small forum software, so on the homepage I want to list categories and the forums that belong to the category underneath. I'm used to making a while loop inside a while loop, so I have no idea how to do this with CodeIngiter. Please let me know if that didn't make much sense How to do this? - El Forum - 07-26-2012 [eluser]InsiteFX[/eluser] foreach How to do this? - El Forum - 07-27-2012 [eluser]Mahn[/eluser] Yes, but the query will be different each time. Something like Code: SELECT * FROM forums WHERE category_id = $category['id'] How to do this? - El Forum - 07-27-2012 [eluser]DarkManX[/eluser] you wont be able to avoid learning php. you should start by pure php without frameworks etc. there are enough good tutorials. How to do this? - El Forum - 07-27-2012 [eluser]Mahn[/eluser] @DarkManX: Why would you assume that? I've done this many times before with procedural PHP. I just can't make sense of how to do this with a model. How to do this? - El Forum - 07-27-2012 [eluser]InsiteFX[/eluser] Controller Code: $data['cats'] = 'get the query from your model'; Something like that. How to do this? - El Forum - 07-28-2012 [eluser]Mahn[/eluser] @InsiteFX: I've already got the categories done, it;s just the forums that are a bit tricky because the query changes every time. How to do this? - El Forum - 07-28-2012 [eluser]DarkManX[/eluser] The model just returning you the date from the db. fetch them all in to an array and give it all to the view. How to do this? - El Forum - 07-28-2012 [eluser]Mahn[/eluser] @DarkManX: Yes, but the query changes for every category, so I can't just query for everything. The query will look something like: Code: SELECT * FROM forums WHERE category_id = $category['id'] How to do this? - El Forum - 07-28-2012 [eluser]DarkManX[/eluser] Just get all categories and create a db-request for each of them. as i told, you wont be able to avoid learing php. Code: $all_cats = // get all cat, how every you want/got to this way you could use $all_my_stuff in the view. |