为每个循环返回for循环中的no计数

A variable already iterating in for loop, and inside the for loop I am checking with a condition inside the another foreach loop, but it returning a values of n number of iteration in first for loop.

Actually I need, for foreach result value should corresponding one by one in the loop not a whole result value iterating in the loop and again and again iterating

Here $full_date have every 30 minutes time in td block, and $cal_eve is the number of event in particular list.

By this query $start_time have two dates and timing and $end_time date having two dates and timing

$cal_eve = $this->db->query("SELECT * FROM `jqcalendar` WHERE `list_id` = '".$list_id."'")->result();
$full_date=$month.'/'.$curday.'/'.$year."00:00:00";

for($t=0;$t<48;$t++)
{

$full_date = date("Y-m-d H:i:s",strtotime("+30 minutes",strtotime($full_date)));

if(strtotime($full_date) < $currenttime) { ?>

                            <tr><td id="day_<?php echo $i; ?>" class="weekend in_the_past">
        <?php // echo get_currency_symbol($list_id)." ".get_currency_value1($list_id,$price); ?>
            </td></tr>      

            <?php }  else {

    if(!empty($cal_eve)){

    foreach($cal_eve as $row){

    if($full_date >= $row->StartTime && $full_date <= $row->EndTime ){

         $pre_schedules ="<tr><td class='realday available'>".$full_date."##".$row->StartTime."@@".$row->EndTime."</td></tr>";

    }else{

         $pre_schedules = "<tr><td class='realday unavailable'>".$full_date."##".$row->StartTime."@@".$row->EndTime."</td></tr>";
    } 
    }
    }else{
         $pre_schedules = "<tr><td class='realday unavailable'>".$full_date."##".$row->StartTime."@@".$row->EndTime."</td></tr>";
    } 

echo $pre_schedules;
       }

}