mysqli fetch_assoc double results
Posted: Thu Aug 05, 2010 10:11 am
I'm getting double results with this (error checking removed & output simplified for clarity):
Initially I attributed this to the fact that I was using mysqli_fetch_array, but changing that to fetch_assoc didn't solve the problem.
You can see the output here.
Thanks,
Code: Select all
<?php $link = mysqli_connect('p:localhost', 'login', 'password');
$db = mysqli_select_db($link, 'dbname');
$takebake = mysqli_query($link, 'SELECT id, name FROM pages WHERE id > 200 AND id < 401 ORDER BY name');
while ($row = mysqli_fetch_assoc($takebake)) {
$meals[] = $row;
}
?>
<?php foreach ($meals as $name): ?>
<?php echo '<li><a href="?page=meal'.$name['id'].'" name="meal['.$name['id'].']" title="'.$name['name'].'">'.$name['name'].'</a></li>
<li class="portions">
<input id="mealSP-'.$name['id'].'" name="mealSP['.$name['id'].']" />
<label for="mealSP-'.$name['id'].'">Single Portion</label>
</li>
<li class="portions">
<input id="mealFP-'.$name['id'].'" name="mealFP['.$name['id'].']" />
<label for="mealFP-'.$name['id'].'">Family Pack</label>
</li>'; ?>
<?php endforeach ?>You can see the output here.
Thanks,