Welcome Guest, Not a member yet? Register   Sign In
Break a Foreach Loop
#6

[eluser]brianw1975[/eluser]
I think you should fix your query so that $items is only as big as you need. It's detrimental to get 100 rows if you are only going to show 8 of them

Code:
$this->db->limit(8);

@noxie: not have your coffee yet? lol $limit is not being updated anywhere, i think you mean
Code:
if($constrict >= 8)
{
  break;
}

As for the second example another(better?) way would be :
Code:
<?php
$limit = 8;
for($constrict = 1; $constrict <= $limit; $constrict++)
{}


Messages In This Thread
Break a Foreach Loop - by El Forum - 09-09-2009, 10:15 AM
Break a Foreach Loop - by El Forum - 09-09-2009, 10:22 AM
Break a Foreach Loop - by El Forum - 09-09-2009, 10:29 AM
Break a Foreach Loop - by El Forum - 09-09-2009, 10:31 AM
Break a Foreach Loop - by El Forum - 09-09-2009, 10:35 AM
Break a Foreach Loop - by El Forum - 09-09-2009, 10:37 AM
Break a Foreach Loop - by El Forum - 09-09-2009, 10:43 AM
Break a Foreach Loop - by El Forum - 09-09-2009, 11:11 AM
Break a Foreach Loop - by El Forum - 09-10-2009, 02:03 AM
Break a Foreach Loop - by El Forum - 09-10-2009, 02:25 AM
Break a Foreach Loop - by El Forum - 09-10-2009, 02:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB