tags:

views:

53

answers:

2

I have never had this happen before. The query is very simple by the way.

$q  = mysql_query("SELECT * FROM $TABLE");  
while($r = mysql_fetch_array($q)) {  
    echo $r['fieldname'];  
}

edit: the first column (row) is skipped. but when I deleted the first column, the second one was ignored.

(SOLVED)

I figured it out. I declared mysql_fetch_array twice.

$q  = mysql_query("SELECT * FROM $TABLE");    
$r = mysql_fetch_array($q) //over here 


while($r = mysql_fetch_array($q)) {  
        echo $r['fieldname'];  
}

I have to be more careful, but thank you very much!

+1  A: 

Every thing seems okey, but it worth trying with MYSQL_ASSOC

$q  = mysql_query("SELECT * FROM $TABLE");  
while($r = mysql_fetch_array($q,MYSQL_ASSOC)) {  
    echo $r['fieldname'];  
}
JapanPro
Why not using mysql_fetch_assoc() then? mysql_fetch_array returns as BOTH numeric and associative array.
halfdan
thats right , i was trying to working of question, instead i could suggested to use some standard class for these jobs.
JapanPro
+3  A: 

You should always use full list of columns in your select statement. Code you have posted is an example of bad programming. Do it this way

$q  = mysql_query("SELECT fieldname FROM $TABLE");  
while($r = mysql_fetch_array($q)) {  
    echo $r['fieldname'];  
}
vucetica
This should really be a comment since you don't answer the question. +1 though because it is good advice.
Dennis Haarbrink