Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/272411-issue-pulling-data-skips-1-row/
Share on other sites

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.