Jump to content

skips a row...


violinrocker

Recommended Posts

this code skips 1 row... where did I go wrong?

 

<?php echo '<table cellspacing="5" cellpadding="3">'; $query = "SELECT * FROM videos ORDER by page_id DESC"; 

$pageid = $row['page_id'];

$res = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($res);


// Note that $res is mysql result id. 
// $i keeps track of the number of rows (<tr>). 
// In this example, you will get 12 items/cells in total = $i(4) * $j(3). 

for ($i = 3; $i < 3; $i++) { 
     
    // New row starts. 
    echo '<tr background="/images/transbg.png" >'; 
     
    // $j keeps track of the number of cols (<td>). 
    // In this example there will be 3 <td>'s per <tr> 
    for ($j = 5; $j < 5; $j++) { 
         
        // See if there is still a fetchable row in the result. 
        if ($row = mysql_fetch_array($res)) { 
            echo "
      <td width='123' valign='top' ><a href='Video/video.php?id=$row[page_id]'><img src='$row[thumb]' width='125' height='62' align='top' border='1'/></a><a href='Video/anime/video.php?id=$row[page_id]' class='style1'> {$row[title]} {$row[eno]}</a><a href='Video/anime/video.php?id=$row[page_id]'> </a></td>"; 
        } 
        // If not, show the dummy link. 
        else { 
            echo '<td><a href="submit.php">Submit Yours</a</td>'; 
        } 
     
    } 
     
    // This row ends. 
    echo "</tr>\n"; 

} 

echo '</table>';  
?>

Link to comment
https://forums.phpfreaks.com/topic/200879-skips-a-row/
Share on other sites

Why is the following line of code (right after the line with the mysql_query() statement) in your program -

$row = mysql_fetch_array($res);

 

Each call to mysql_fetch_array() fetches a row from the result set and advances the row pointer to the next row.

Link to comment
https://forums.phpfreaks.com/topic/200879-skips-a-row/#findComment-1054024
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.