Jump to content

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