-
How to set table cols and rows
I'm trying to make a table of images that I have stored in a database. When it prints out the images they are in a straight line horizontal or vertical, is there a way I can tell the table how many cols I want and the spill over will start a new row?
Example. I want 3 cols and 3 rows
Last edited by sinox; 05-24-2007 at 01:35 AM.
-
-
You can develop an HTML table based on the number of rows and columns you need and that will solve your problem
-
-
<table>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>4</td><td>5</td><td>6</td></tr>
<tr><td>7</td><td>8</td><td>9</td></tr>
</table>
to output that from a database, simply create a loop.
for ($i=0;$i<3;$i++) ... that will go every three times,
then you can create the rest of it.
So, something like--
echo "<table><tr>\n";
foreach ($images as $image) {
echo "<td><img src=\"$image\" alt=\"image\"></td>";
$i++;
if ($i%3 == 0) {echo "</tr><tr>"; }
}
echo "</tr></table>";
Last edited by djr33; 05-24-2007 at 05:19 AM.
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks