Jump to content

Grid


verdrm

Recommended Posts

What do you mean. You don't need PHP for that. Anyways, you can do this:

 

<?php
echo "<table>";
for ($i = 0; $i <= 10; $i++) {
    echo "<tr>";
    for ($j = 0; $j <= 4; $j++) {
        echo "<td>test</td>";
    }
    echo "</tr>";
}
echo "</table>";
?>

Link to comment
Share on other sites

this is how i do mine...

 

<table>
<tr>

<?php
while($row2 = mysql_fetch_assoc($result)){       
   if ($x % 3 == 0) {// change the number to number of columns wanted
     echo '</tr><tr>';
   }
   $x++;
echo '<td>';


the info in each colum

echo '</td>';

}
?>
</tr>
</table>

Link to comment
Share on other sites

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
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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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