count!! - 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: count!! (/showthread.php?tid=28246) |
count!! - El Forum - 03-05-2010 [eluser]Shaileen[/eluser] How can i count the total number of rows in my table.. 1 keyword I am aware of is sizeof.. but how can i count the number of rows in multiple tables.. count!! - El Forum - 03-05-2010 [eluser]InsiteFX[/eluser] Hi, I do suggest that you read the CodeIgniter user's guide. Code: echo $this->db->count_all('my_table'); Enjoy InsiteFX count!! - El Forum - 03-05-2010 [eluser]Shaileen[/eluser] can i use this in my view?? count!! - El Forum - 03-05-2010 [eluser]Shaileen[/eluser] I want something that i can count from my view table and not database table.. count!! - El Forum - 03-05-2010 [eluser]InsiteFX[/eluser] Well how are you populating your view table? Your not showing any code for your view. Enjoy InsiteFX count!! - El Forum - 03-08-2010 [eluser]Shaileen[/eluser] ok..here is the code for my view : <div style = " float: left;background:#ffcc00; width:1645px; height:20px; font-family: Verdana,Tahoma,Arial; font-weight:800; font-size: 10pt; color: black; position: absolute; top: 130px; left: 10px;"> Current Orders <font style="float : right; font-family: Verdana,Tahoma,Arial; font-size: 8pt; color: black;">Total : <?=$sent;?></font> </div> <div style = " float: left;background:#ffcc00; width:1645px; height:20px; font-family: Verdana,Tahoma,Arial; font-weight:800; font-size: 10pt; color: black; position: absolute; left: 10px;"> Cancelled Orders <font style="float : right; font-family: Verdana,Tahoma,Arial; font-size: 8pt; color: black;">Total : <?=$sent; ?></font> </div><br><br> <div style = " float: left;background:#ffcc00; width:1645px; height:20px; font-family: Verdana,Tahoma,Arial; font-weight:800; font-size: 10pt; color: black; position: absolute; left: 10px;"> Deleted Orders <font style="float : right; font-family: Verdana,Tahoma,Arial; font-size: 8pt; color: black;">Total : <?=$sent; ?></font> </div><br><br> And here is the query i am calling through the controller : $data['result'] = $this->t1_orders_search2_model->query3($AUTH->user_id, $inyc_limit, $field, $order, $searchField, $searchText, $groupSearch ); $data['sent'] = sizeof($data['result']); count!! - El Forum - 03-08-2010 [eluser]Maglok[/eluser] Seems awefully complicated. Do you not use a CSS? InsiteFX is very correct though, CI comes with a count_all() function in the db class (see user_guide) which you can use. If you go in your controller (or model): Code: $data['sent'] = $this->db->count_all('table_name'); count_all() returns an int which you can then use in your view by echo-ing it: <?php echo $sent; ?> count!! - El Forum - 03-08-2010 [eluser]Shaileen[/eluser] guys, you are not getting what my question is!! I do not want to get the number of rows from my database table..I want to count how many rows in my output is from my db query.. count!! - El Forum - 03-08-2010 [eluser]Maglok[/eluser] In that case: $this->db->count_all_results(); Read up: http://ellislab.com/codeigniter/user-guide/database/active_record.html count!! - El Forum - 03-10-2010 [eluser]WanWizard[/eluser] These are all still count queries, and I think the OP asks a different question. You find the number of records in the result set with: Code: $query = $this->db->query('SELECT * FROM my_table'); See the manual. |