counting for a reply - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: counting for a reply (/showthread.php?tid=24034) Pages:
1
2
|
counting for a reply - El Forum - 10-28-2009 [eluser]marjune[/eluser] eh pipzz, in have a sample forum using ci, in my controller i joined the topic and account table in getting the topic, views, date posted, and the author for the topic which is ok, but my problem is "counting the the reply in every topic" my controller Code: function furom(){ my model Code: function furomcontent(){ my views Code: <?php counting for a reply - El Forum - 10-29-2009 [eluser]InsiteFX[/eluser] If you can count the replies in your foreach loop then just keep a counter of them, then after your foreach loop exits echo out the counter value. Enjoy InsiteFX counting for a reply - El Forum - 10-29-2009 [eluser]marjune[/eluser] what i have done before is loading the model inside the foreach loop by passing the id then in the model i count the reply in the reply table but it didn't work counting for a reply - El Forum - 10-29-2009 [eluser]InsiteFX[/eluser] Do you have a reply field in your database table? How are you defining your replies? Enjoy InsiteFX counting for a reply - El Forum - 10-29-2009 [eluser]marjune[/eluser] i dont have a reply field in my table, i just count the id's in the reply table then those id's is a primary key from the topic table!! counting for a reply - El Forum - 10-29-2009 [eluser]InsiteFX[/eluser] If your counting them then put it in a variable end then echo it out. Enjoy InsiteFX counting for a reply - El Forum - 10-29-2009 [eluser]marjune[/eluser] thats my problem if how can i count inside the foreach loop passing the id to the other model function counting for a reply - El Forum - 10-29-2009 [eluser]InsiteFX[/eluser] Try this: Code: <?php $count = 0; You may need to take off the $count-1 and just use $count. Enjoy InsiteFX counting for a reply - El Forum - 10-29-2009 [eluser]marjune[/eluser] can i load a model function inside the foreach loop where i can count the reply from the data base table?, its not just $count counting for a reply - El Forum - 10-29-2009 [eluser]InsiteFX[/eluser] I would load your model in your controller then get your count and pass the information to your view. Example: Code: class Welcome extends Controller { Enjoy InsiteFX |