I am trying to make a loop. Something like this:
I have 1000 records. Within this 1000 records it should take
- first 200
- then 201-400
- then 401-600
- then 600-800
- then 801-1000
This is my code:
for($i=1; $i<=1000; $i++){
if($i > 200){
//$this->db->save(); //save some data
break;
}
echo $i."<br>";
if($i == 200){
for($i=201; $i<=400; $i++) {
//$this->db->save(); //save some data
echo $i."<br>";
}
}
if($i == 400) {
for($i=401; $i<=600; $i++){
echo $i."<br>";
}
}
Part 2:
$totalClientCount = 1000;
$input_array = range(1, $totalClientCount);
$chunks = array_chunk($input_array, 200);
foreach ($chunks as $k => $chunk) {
if ($k == 0) { // 0-200
$this->db->where('AccountNo', $id);
//$this->db->limit($offset,$limit);
$getClientDetails = $this->db->get('table');
echo '<pre>';
print_r($getClientDetails);
}
This is where I am stuck. How do I execute this properly?