stopblackholes Posted January 29, 2007 Share Posted January 29, 2007 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 More sharing options...
ted_chou12 Posted January 29, 2007 Share Posted January 29, 2007 sorry, i dont understand, how is <br> related to this?Ted Link to comment https://forums.phpfreaks.com/topic/36148-output-images-into-tables/#findComment-171774 Share on other sites More sharing options...
stopblackholes Posted January 29, 2007 Author Share Posted January 29, 2007 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"; } Link to comment https://forums.phpfreaks.com/topic/36148-output-images-into-tables/#findComment-171779 Share on other sites More sharing options...
HuggieBear Posted January 29, 2007 Share Posted January 29, 2007 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.jpgimage.jpgimage.jpgimage.jpgimage.jpgimage.jpg[/color]They want:[color=green]image.jpg image.jpg image.jpgimage.jpg image.jpg image.jpg[/color]RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/36148-output-images-into-tables/#findComment-171782 Share on other sites More sharing options...
ted_chou12 Posted January 29, 2007 Share Posted January 29, 2007 Oh, no problem. according to HuggieBear's eg.:[code]<table><tr><?php$read = 1; //set read as one firstwhile ("***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 problemTed Link to comment https://forums.phpfreaks.com/topic/36148-output-images-into-tables/#findComment-171784 Share on other sites More sharing options...
Nelak Posted January 29, 2007 Share Posted January 29, 2007 i know this isnt my post but can sum1 explain to me how modulus works and how and what % does pls ;)cos i cud do with something like this. Thanks in advance,Chris Link to comment https://forums.phpfreaks.com/topic/36148-output-images-into-tables/#findComment-171797 Share on other sites More sharing options...
ted_chou12 Posted January 29, 2007 Share Posted January 29, 2007 modulus is just like divison, however, different to typical division, it returns the remainder instead of a value that is the product of a fraction.Ted Link to comment https://forums.phpfreaks.com/topic/36148-output-images-into-tables/#findComment-171800 Share on other sites More sharing options...
stopblackholes Posted January 30, 2007 Author Share Posted January 30, 2007 Thanks for the help ted i think i have it figured out. Im just defining max rows and columns and using for ($i=0; $i<MAX_ROWS; $i++). Im not sure what way is better but it works.Thanks again. Link to comment https://forums.phpfreaks.com/topic/36148-output-images-into-tables/#findComment-172593 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.