Swarfega Posted December 27, 2012 Share Posted December 27, 2012 Hey. I've got an issue with my script. The Data is pulled from the database, but for some reason the printed Data skips 1 Row, which is not what it's supposed to do. It pulls the rest of them quite successfully, but the fact that it skips 1 ruins the whole point of the script. Here's a picture of the Database Table Data, currently: http://i45.tinypic.com/2hdw1sx.png Here's a picture of the Printed Data on the website: http://i49.tinypic.com/2ylkcj6.png And here's the code if($_SESSION['SESS_MEMBER_ID'] == $data['uid']) { $sql = "SELECT * FROM grannar where uid='".$data['uid']."' ORDER BY targetname"; $query = mysql_query( $sql ); $rows = mysql_nuM_rows( $query ); $data = NULL; echo '<div class="sidebar" id="sideRight3">'; echo '<div class="sidebar" id="sideRight4">'; echo '<strong><center> - Mina Grannar -</center></strong>'; echo '</div>'; if($rows == 0) { echo 'Du har tyvärr inga grannar ännu.'; } if($query) { $row = mysql_fetch_array($query); $table_start = "<table border='0' style='color: #8e0046;'> <tr> </tr>"; $table_end = "</table>"; while($row = mysql_fetch_array($query)) { $data .= "<tr>"; $data .= "<td><img src='".$row['profilepic']."' width='30' height='30'>"; if($row['connected'] == "online") { $data .= "<td><img src='online.png' width='5' height='5'> <a href='profile.php?uid=".$row['targetid']."'>" . ucfirst($row['targetname']) . "</a></td>"; } else { $data .= "<td><img src='offline.png' width='5' height='5'> <a href='profile.php?uid=".$row['targetid']."'>" . ucfirst($row['targetname']) . "</a></td>"; } //echo ' <img src="'.$image.'" width="30" height="30"><a href="profile.php?uid='.$row['targetid'].'"><font size="3">'.$fname .' ' .$lastname. '</font>'; $data .= "</tr>"; } echo $table_start . $data . $table_end; echo '</div><!-- .sidebar#sideRight -->'; } } As you can see it skips 1 Row/Record of the Pulled Data, and I can't figure out why. Thanks! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 27, 2012 Share Posted December 27, 2012 Your code is missing the first row because you have the following line of code that is fetching and discarding the first row in the result set - $row = mysql_fetch_array($query); Why do you have that line of code in your code? Quote Link to comment Share on other sites More sharing options...
Swarfega Posted December 27, 2012 Author Share Posted December 27, 2012 Wow I can't believe I didn't see that.. Sorry! And thanks for the help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.