Jump to content

Table With Fetch


Cloud9247

Recommended Posts

I have been developing my graphics site lately, and I have run into a problem. Currently I am setting up a 100x100 avatars page, and I am using mysql_fetch_array. I want it to have in each row of avatars, 4 avatars per row. and I am currently using tables for this, so can someone help me get it to where every 4 rows it inserts a '<tr>' and '</tr>', so I could get more rows?
Link to comment
https://forums.phpfreaks.com/topic/14210-table-with-fetch/
Share on other sites

[code]
<?php
$sql = "some query";
$result = mysql_query($sql);
$i = 0;
echo "<table><tr>";
while ($list = mysql_fetch_array($result)) {
  echo "<td>{$list['columnamehere']}</td>";
  if ($i == 3) {
      echo "</tr><tr>";
      $i = 0;
  }
  $i++;
}
echo "</tr></table>"
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/14210-table-with-fetch/#findComment-55762
Share on other sites

[code]
<?php
echo $top1.'Avatars'.$top2.$body1;
echo '<table id= "avatars"><tr>';
$i= 0;
        $sqll= "SELECT userid, id, clicks, username, submitted, name, credits, comments, series, imgurl, active FROM avatars WHERE active='1' ORDER BY `id` DESC LIMIT $from, $max_results"; // LIMIT $from, $max_results
$rss= mysql_query( $sqll, $connection );
while($row= mysql_fetch_array( $rss )) {


$dwn= "return false;";


echo '<td id= "avi"><a href= "http://hayalkarga.com/designs.php?viewavatar='.$row['id'].'"><img src= "'.$row['imgurl'].'" id= "graphic" alt= "'.$row['name'].'" oncontextmenu="return false"></a></td>';

  if ($i == 3) {
      echo "</tr><tr>";
      $i = 0;
  }
$i++;
}
echo '</tr></table>';
echo $body2.$foot1.$foot2;
[/code]

comes out as: http://hayalkarga.com/designs.php?designs=avatars

It prints out 4 on the first row, but only 3 on the others. Can someone help me fix this?
Link to comment
https://forums.phpfreaks.com/topic/14210-table-with-fetch/#findComment-55795
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.