I have always looped through a database to display the results as in
I have been reading up on some new php tutorials and they all seem to output to an array then print the array
None of the tutorials state why they are choosing to use this method. I guess it is for speed but will it be faster whe you fetch back many records?
Code:
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) : ?>
<tr>
<td><?php echo $row['id'];?></td>
I have been reading up on some new php tutorials and they all seem to output to an array then print the array
Code:
$stmt = $db->prepare($query);
$stmt->execute();
$rows = $stmt->fetchAll();
<?php foreach($rows as $row): ?>
<td><?php echo $row['id']; ?></td>
<?php endforeach; ?>
None of the tutorials state why they are choosing to use this method. I guess it is for speed but will it be faster whe you fetch back many records?