help on how to loop .. displaying all data on database.. - 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: help on how to loop .. displaying all data on database.. (/showthread.php?tid=56613) |
help on how to loop .. displaying all data on database.. - El Forum - 01-07-2013 [eluser]besingamk[/eluser] hi im new on codeigniter and i cant loop this one.. please help me. all i need is to loop the codes as long as it has data on database heres my controler: Code: public function homepage() and heres my model: Code: <?php heres my view: Code: <?php help on how to loop .. displaying all data on database.. - El Forum - 01-07-2013 [eluser]Rowan Wilson[/eluser] Something like this: Code: <?php if ($result): ?> help on how to loop .. displaying all data on database.. - El Forum - 01-07-2013 [eluser]besingamk[/eluser] Thank you sir.. I hope thats its the answer to my problem.. help on how to loop .. displaying all data on database.. - El Forum - 01-07-2013 [eluser]besingamk[/eluser] [quote author="Rowan Wilson" date="1357559740"]Something like this: Code: <?php if ($result): ?> sir how about if i want 5 items only to be display.. ?? help on how to loop .. displaying all data on database.. - El Forum - 01-07-2013 [eluser]Rowan Wilson[/eluser] Quote:sir how about if i want 5 items only to be display.. ?? In your model: Code: $query = $this->db->query("SELECT * FROM film WHERE film_id = film_id ORDER by film_id DESC LIMIT 5"); Have a look into Active Record though. Unless your query is massively complicated it will do all that you require: http://ellislab.com/codeigniter/user-guide/database/active_record.html That way you can pass through the limit from your controller/view. If you so wish. help on how to loop .. displaying all data on database.. - El Forum - 01-07-2013 [eluser]besingamk[/eluser] i am very thankful for your reply sir. it helps me a lot to my project and to understand CI more.. |