Hey there :wub: Anyway, I have a page which shows 6 pictures. I did this with a "for" loop, from 1 to 6. the adresses of the images are stored in a database. now I want to add a second page, with images 7 to 12. I want it to be automated, is it possible? like: <_< <_< <_< <_< <_< <_< next page :blink: :blink: :blink: :blink: :blink: :blink: previos page (the smilies are the images). and something extra, if i have 4 pictures, can I make the remaining pictures be the same (ie preview.jpg). will give some credits for anyone who helpes, and 70 for the one who scores! THANKS
From what i know..i'm pretty sure you can't "automate" it but you can add a link to the next one.....Hope that helps...
ill do this, give me a min Merged Post: Done! Here is the source: Code: <?php mysql_connect( "localhost", "username", "password" ); // Use correct stuff there mysql_select_db( "images" ); // Use Database Name $max_images = 8; if( !isset( $_GET[ 'page' ] ) ) { $page = 1; } else { $page = $_GET[ 'page' ]; } $from = ($page * $max_images) - $max_images; // select the image url's from the db, i_id = the id of the row in the mysql db $sql = "SELECT * FROM images ORDER BY i_id LIMIT $from, $max_images"; $s = mysql_query( $sql ); while( $res = mysql_fetch_array( $s ) ) { $i = 1; //example variables, might be different for you // assuming the row name is "src" $src = $res[ 'src' ]; echo '[img]'.$src.'[/img] '; if( $i > 4 ) { echo ' '; } $i++; } echo ' '; $total_images = mysql_result( mysql_query( "SELECT COUNT( i_id ) as Num FROM images" ), 0 ); $total_pages = ceil( $total_images / $max_images ); // previous page if($page > 1){ $prev = ( $page - 1 ); echo '[url="images.php?page='.$prev.'"]Previous[/url] '; } for( $i = 1; $i <= $total_pages; $i++ ) { if( ( $page ) == $i ) { echo "$i "; } else { echo '[url="images.php?page='.$i.'"]$i[/url] '; } } // next page if( $page < $total_pages ) { $next = ( $page + 1 ); echo '[url="images.php?page='.$next.'"]Next[/url]'; } ?> example in action: http://clanwng.com/imagescript/images.php
Thanks, johndapunk FTW. Let's say I don't want an image, I want an include. The include is a table with variables (for the image and link) - table.txt. I want only to include 6 in a page. And another thing: If there are only 4 includes left in a page, can the rest be another include | include 'table.txt' | | include 'table.txt' | | include 'table.txt' | | include 'table.txt' | | include 'no.txt' | | include 'no.txt' | I'll give you all my credits if you can manage this one. Thanks
I think I'll make a page called 'tables.php' with a table in it with two rows and three columns, inside every cell I'll put an <? include ('table.php'); ?>. 'tables.php' will connect to a specific database via a var ('tables.php?cat=cat1'). Then I want it to check how many rows are in that database. I want up to 6 <? include ('table.php'); ?>. in a page. So, if for example I have 10 rows in database 'cat1', I'll have a page with 6 <? include ('table.php'); ?>, and a second page with 4 <? include ('table.php'); ?>, And two <? include ('table-no.php'); ?>, 'tables.php?cat=cat1?id=0': <? include ('table.php'); ?>, <? include ('table.php'); ?>, <? include ('table.php'); ?>, <? include ('table.php'); ?>, <? include ('table.php'); ?>, <? include ('table.php'); ?>, next 'tables.php?cat=cat1?id=1': <? include ('table.php'); ?>, <? include ('table.php'); ?>, <? include ('table.php'); ?>, <? include ('table.php'); ?>, <? include ('table-no.php'); ?>, <? include ('table-no.php'); ?>, previous
yeah, totally dont get what you're trying to do. just trying to include 6 pages of stuff into 6 tables on a page?
I have 5 dif databases. I want the script to: 1. <? $_get ?> the specific database 2. check how many rows are in it 3. for every row do <? include (table.php) ?> 4. if there are no rows left to complete the 6 rows limit do <? include (table-no.php) ?> 5. pagination