Jump to content

Grid


verdrm

Recommended Posts

my code:

<?php $dn = mysql_query("SELECT * FROM `3`") or die(mysql_error());
echo '<div class="bord"><table width="100%"><tr>';
$i = 0;
while ($row = mysql_fetch_array($dn)){

echo '<td><center><a href="?p='.$row['ID'].'"><img src="'.$row['img'].'" width="130" height="105"><br>'.$row['name'].'</center></a></td>';


$i++;
if ($i % 3 == 0 ){
echo '</tr><tr><td><hr></td><td><hr></td><td><hr></td></tr><tr>';
// Above there, i just liked hr's, if you dont want them, just change it to this line: echo '</tr><tr>';
}

}
echo '</tr></table></div>';
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/97418-grid/#findComment-498524
Share on other sites

I need to arrange the following into a THREE COLUMN PER ROW layout. How would I do that (this code below makes one box)?

 

echo "<table width=\"148\">";

  <tr>

    <td width=\"67\" height=\"67\" align=\"right\"><img src=\"$img\" width=\"67\" height=\"67\" /></td>

    <td width=\"71\" align=\"center\"><strong><span class=\"large\">$per%</span></strong></td>

</tr>

  <tr>

    <td height=\"21\" colspan=\"2\" align=\"center\">$response [ $q ]</td>

  </tr>

</table>";

 

Link to comment
https://forums.phpfreaks.com/topic/97418-grid/#findComment-498648
Share on other sites

go to my code above....

 

ok, so the table obvisouly sets up the grid.

The first

 

<table>
<tr>

<?php
while($row2 = mysql_fetch_assoc($result)){       
   if ($x % 3 == 0) {// The $x++ below keeps track of the amount of columns created. The % calues the remainder when divided by...
     echo '</tr><tr>';// for example, if $x is 3 (3 columns created so far) then 3 / 3 gives a remiander of 0, so it ends that row, and creates a new one
   }// after 6,9,12,15, etc. columns are created, the remainder is 0, so a new row is started. 
   $x++;
echo '<td>';//This creates a column


the info in each colum

echo '</td>';//this end the column

}
?>
</tr>
</table>

Link to comment
https://forums.phpfreaks.com/topic/97418-grid/#findComment-498926
Share on other sites

Sorry guys, would someone mind taking this and making it into a three column system? Something is throwing me off here; maybe it is the fact that my boxes are actually each complete tables.

 

I need three of these per row...I would really appreciate it if someone could write up the code for this:

 

 

echo "<table width=\"148\">";

  <tr>

    <td width=\"67\" height=\"67\" align=\"right\"><img src=\"$img\" width=\"67\" height=\"67\" /></td>

    <td width=\"71\" align=\"center\"><strong><span class=\"large\">$per%</span></strong></td>

  </tr>

  <tr>

    <td height=\"21\" colspan=\"2\" align=\"center\">$response [ $q ]</td>

  </tr>

</table>";

Link to comment
https://forums.phpfreaks.com/topic/97418-grid/#findComment-499228
Share on other sites

<?php
$query = mysql_query("SELECT * FROM `foo`") or die(mysql_error());
echo '<table width="148"><tr>';

while ($row = mysql_fetch_array($query)){

  echo '<td width="67" height="67" align="right"><img src="'.$row[img].'" width="67" height="67"></td>
    <td width="71" align="center"><strong><span class="large">'.$row['per'].'</span></strong></td>
    <td colspan="2" align="center">'.$row['q'].'</td>
  </tr><tr>';

}

echo '</tr></table>';

?>

 

 

Is this what you want? Im not quite sure what you want here...

Link to comment
https://forums.phpfreaks.com/topic/97418-grid/#findComment-499315
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.