Jump to content

output images into tables


stopblackholes

Recommended Posts

How can i output this into say 2 tables that hold 36 images a piece instead of using a simple br tag.
PHP Code:[code]
<?php


// number of images
$num = "72";

$galleries = file("gallery.txt");

shuffle($galleries);

for($i=0; $i<$num; $i++) {

$data = explode("|", $galleries[$i]);

if(strlen($data[1]) > 5) {
print("<A HREF=$data[0]><img src="$data[1]" alt="$data[2]" border="0"></A><BR>\n");
}

}

?> [/code]
Link to comment
https://forums.phpfreaks.com/topic/36148-output-images-into-tables/
Share on other sites

Im trying to make a php photo album. I see so many free ones but all way to complex for my needs and most use a database. I want to start from scratch and build something simple that just loads a single text file with pipes seperating the data that i need to display.

Ive been trying to find a tutorial or something related to this for awhile and I'm still stuck at square one.

if ( $table_output ) {


if ( $galleries_count = count_galleries ( $galleries ) ) {
$max_rows = ceil( $galleries_count / 4 );
} else {
$max_rows = 0;
}


echo '<table width="100%" cellspacing="0" cellpadding="0" border="1">' . "\n";
echo ' <tr>' . "\n";
echo ' <td valign="top">' . "\n";

}
Ted,

The OP wants their images displayed in a table, not just one after the other on the page.

So rather than this:

[color=green]image.jpg
image.jpg
image.jpg
image.jpg
image.jpg
image.jpg[/color]

They want:
[color=green]image.jpg    image.jpg    image.jpg
image.jpg    image.jpg    image.jpg[/color]

Regards
Huggie
Oh, no problem. according to HuggieBear's eg.:
[code]
<table><tr>
<?php
$read = 1; //set read as one first
while ("***your mysql query***") {
echo "<td><img src=""></td>";
if ($read % 3 = 0) {echo "</tr><tr>";}//since each row has three columns therefore, we have a modulus of 3 here
$read ++;}
?>
</tr>
</table>
[/code]
Tell me if this solves the problem
Ted

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.