count!! |
[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..
[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
[eluser]Shaileen[/eluser]
I want something that i can count from my view table and not database table..
[eluser]InsiteFX[/eluser]
Well how are you populating your view table? Your not showing any code for your view. Enjoy InsiteFX
[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']);
[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; ?>
[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..
[eluser]Maglok[/eluser]
In that case: $this->db->count_all_results(); Read up: http://ellislab.com/codeigniter/user-gui...ecord.html
[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. |
Welcome Guest, Not a member yet? Register Sign In |