mysql_fetch_array skipping first row

后端 未结 5 1008
旧巷少年郎
旧巷少年郎 2020-11-30 15:25

EDIT : Thanks for the quick responses guys - I ended up switching to mysql_fetch_assoc() and using a do...while and I am good to go.

I am using this

5条回答
  •  无人及你
    2020-11-30 15:52

    You are calling mysql_fetch_array twice... once before the loop then once while looping.

    If you need a seed row for use in building your header row you might be better served with a do.. while loop here.

    $query = "SELECT * FROM members";
    $results = mysql_query($query);
    $row = mysql_fetch_assoc($results);
    
    //echo my  start and headings;
    
    do  
    {
        echo "";
        echo "";
        echo "";
        echo "";
        echo "";
        echo "";
        echo "";
        echo "";
        echo "";
        echo "";
        echo "";
        echo "";
        echo "";
        echo "";
        echo "";
        echo '';
    } while ($row = mysql_fetch_assoc($results));
    
    echo "
    ".$row['Last Name']."".$row['First Name']."".$row['Middle Name']."".$row['Sfx']."".$row['Prf']."".$row['Spouse/SO']."".$row['Ancestor']."".$row['Status']."".$row['Address 1']."".$row['Address 2']."".$row['City']."".$row['ST']."".$row['Zip 5']."".$row['Zip 4']."".$row['Home Phone']."Bio

    ";

提交回复
热议问题