Welcome Guest, Not a member yet? Register   Sign In
count!!
#1

[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..
#2

[eluser]InsiteFX[/eluser]
Hi,

I do suggest that you read the CodeIgniter user's guide.

Code:
echo $this->db->count_all('my_table');

// Produces an integer, like 25

Enjoy
InsiteFX
#3

[eluser]Shaileen[/eluser]
can i use this in my view??
#4

[eluser]Shaileen[/eluser]
I want something that i can count from my view table and not database table..
#5

[eluser]InsiteFX[/eluser]
Well how are you populating your view table?
Your not showing any code for your view.

Enjoy
InsiteFX
#6

[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 : &lt;?=$sent;?&gt;</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 : &lt;?=$sent; ?&gt;</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 : &lt;?=$sent; ?&gt;</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']);
#7

[eluser]Maglok[/eluser]
Seems awefully complicated. Do you not use a CSS? Smile

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: &lt;?php echo $sent; ?&gt;
#8

[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..
#9

[eluser]Maglok[/eluser]
In that case: $this->db->count_all_results();

Read up: http://ellislab.com/codeigniter/user-gui...ecord.html
#10

[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');
echo $query->num_rows();

See the manual.




Theme © iAndrew 2016 - Forum software by © MyBB