Which one of the options below is better
Option 1:
//control file:  
$smpt = $con->query("SELECT id,name FROM customers");
//fetch all resuts 
$results = array();
while ($row = $result->fetch_assoc()) {
  $results[] = $row;
}    
$smpt->close();
//Note: PHP version < 5.3.0 so I can't use just $results->fetch_all('MYSQLI_ASSOC');
//view file:
foreach($results as $key=>$value) {
//display results
}
unset($results);
Option 2:
//control file:  
$smpt = $con->query("SELECT id,name FROM customers");
//fetch all resluts 
//view file:
while($row = $result->fetch_assoc()) {
//display results
}
$smpt->close();
I am trying to completely separate the logic from presentation... Current I am using option 2 because with option 1 the script go through 2 loops. one to fetch data and the other to display them. But which one is better to use?
Thanks
 
     
     
    