mysql query + arrays + while loops returns 1 row too little?
Posted: Wed May 21, 2003 9:07 am
I don't know if this is a common problem or not, but for some weird reason i get one row too little as output. there are 3 rows with id's 1,2,3 but it outputs only 3,2 in that order. I did sort by another variable though, so that's why they come out like that. But why the first one is missing...
Code is structured like this:
now the weird part is that i echo'd back some rowcounts of the queries and it outputs 3 the first time, then 2 the second time:
The product table which gives me the 2 values has 3 rows with 3 null collumns in EACH row.. So there shouldn't be any difference, should there? I read something somewhere about null values using mysql_fetch_array, could that be the problem?
Code is structured like this:
Code: Select all
while query{
echo some stuff
while query{
while query using previous returned id's{
echo some stuff
}
}
}Code: Select all
<?php
//SELECT informatie over product
mysql_select_db($database_neoderma_nl, $neoderma_nl);
$query_producten = "SELECT id, naam, werking_nl, plaatje, werking_en, werking_fr FROM product ORDER BY naam ASC";
$producten = mysql_query($query_producten, $neoderma_nl) or die(mysql_error());
$row_producten = mysql_fetch_array($producten);
$totalRows_producten = mysql_num_rows($producten);
echo $totalRows_producten; ///////////////////OUTPUTS 3!!
?>
<table width="400" border="0" cellpadding="0" cellspacing="0">
<?php
while($row_producten=mysql_fetch_array($producten)){
$productID = $row_productenї0];
echo $productID; ///////////////////OUTPUTS 2!!
$productNaam = $row_productenї1];
$productWerking = $row_productenї2];
?>