violinrocker Posted May 6, 2010 Share Posted May 6, 2010 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>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/200879-skips-a-row/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 6, 2010 Share Posted May 6, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/200879-skips-a-row/#findComment-1054024 Share on other sites More sharing options...
violinrocker Posted May 6, 2010 Author Share Posted May 6, 2010 tnx... I joined two different codes to work as one and I really dont know what to remove and what to add in there... anyways... it works now... Tnx again for showing me my error =) Quote Link to comment https://forums.phpfreaks.com/topic/200879-skips-a-row/#findComment-1054026 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.