realcoder Posted June 24, 2010 Share Posted June 24, 2010 i am fetching some data from my database want to know that how can i show 4 or 5 or etc records in one td then automatic start next tr this is code my code fetching all record in td i want to separte record after few record someone explain my code is like $que = "SELECT * FROM movies where catid='$id'"; $exe = mysql_query($que); while ($get = mysql_fetch_array($exe)){ echo"<td height='400' align='left' valign='top'><a href='songs.php?movie=".$get['name']."'>".$get['name']."<br/><img width='100' height='130' src='".$get['picture']."' /></a> </td>"; please help buddies Link to comment https://forums.phpfreaks.com/topic/205729-how-to-break-while-loop-some-specific-records/ Share on other sites More sharing options...
Glenugie Posted June 24, 2010 Share Posted June 24, 2010 $que = "SELECT * FROM movies where catid='$id'"; $exe = mysql_query($que); while ($get = mysql_fetch_array($exe)){ echo"<td height='400' align='left' valign='top'><a href='songs.php?movie=".$get['name']."'>".$get['name']."<br/><img width='100' height='130' src='".$get['picture']."' /></a> </td>"; If I understand the problem, I have something pretty similar in my code, I went with a simple counter solution as follows: $Column = 1; while ($get = mysql_fetch_array($exe)){ if ($Column==1) { echo "<tr>";} echo"<td height='400' align='left' valign='top'> <a href='songs.php?movie=".$get['name']."'>".$get['name']."<br/> <img width='100' height='130' src='".$get['picture']."' /></a> </td>"; if ($Column==5) { echo "</tr>"; $Column += 1; if ($Column==6) { $Column = 1;} } That will take a new row every 5 records Link to comment https://forums.phpfreaks.com/topic/205729-how-to-break-while-loop-some-specific-records/#findComment-1076535 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.