Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 10-24-2010, 09:35 AM pagination in php
Novice Talker

Posts: 6
Name: =)
Trades: 0
Hi All

I need help with my small code here:


Code:
<table align="center" border="0"><tr>
<?php
$cols_num = 5;
$folder=opendir(".");
$cols = 0;
while ($file = readdir($folder)) {  
$ext = strtolower(substr($file,strrpos($file, ".")+1));
$pics = array("jpg","jpeg","png","gif");
if (in_array($ext,$pics)){
print "<td align='center' width='50' height='50'><img src='$file'></td>";
++$cols;
if ($cols == $cols_num) {
print "</tr><tr>";
$cols = 0;
}
} 
}  
closedir($folder);  
?>
</tr></table>


I want - for example - every 10 icons or 20 in one page ( pagination )

also if I've any error in my code please correct me

thanks in advance

Last edited by Goal; 10-24-2010 at 09:36 AM..
Goal is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-24-2010, 10:54 AM Re: pagination in php
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
Well if it's all one image like that then you can't.
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 10-24-2010, 11:04 AM Re: pagination in php
Novice Talker

Posts: 8
Name: Massimo
Trades: 0
the best is putting the filenames in a database and then working with the sql command "limit"
if you use the filenames taking from the dir is not so easy, maybe you can use some number as suffix like "img_1.jpg"
and then you can use a GET variable to tell the script which has to be the starting image
anyway I suggest to use a database, it's easier
__________________
Start a
Please login or register to view this content. Registration is FREE
at Logo Arena! Get your custom logo designed by
Please login or register to view this content. Registration is FREE
maxi-72 is offline
Reply With Quote
View Public Profile Visit maxi-72's homepage!
 
Old 10-24-2010, 11:59 AM Re: pagination in php
Novice Talker

Posts: 6
Name: =)
Trades: 0
Quote:
Originally Posted by Physicsguy View Post
Well if it's all one image like that then you can't.
see the picture

more than 50 icons in one folder

u can test the code
Goal is offline
Reply With Quote
View Public Profile
 
Old 10-24-2010, 12:28 PM Re: pagination in php
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by Goal View Post
see the picture

more than 50 icons in one folder
And we are supposed to know that from a picture?



http://www.phpbuilder.com/board/show...php?t=10322049
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-24-2010, 12:28 PM Re: pagination in php
Novice Talker

Posts: 6
Name: =)
Trades: 0
Quote:
Originally Posted by maxi-72 View Post
the best is putting the filenames in a database and then working with the sql command "limit"
if you use the filenames taking from the dir is not so easy, maybe you can use some number as suffix like "img_1.jpg"
and then you can use a GET variable to tell the script which has to be the starting image
anyway I suggest to use a database, it's easier
I'm beginner in php language ,, I don't like database for simple codes
Goal is offline
Reply With Quote
View Public Profile
 
Old 10-24-2010, 12:35 PM Re: pagination in php
Novice Talker

Posts: 6
Name: =)
Trades: 0
Quote:
Originally Posted by chrishirst View Post
And we are supposed to know that from a picture?

http://www.phpbuilder.com/board/show...php?t=10322049
u with me or with Physicsguy ?

and what's that link ?
Goal is offline
Reply With Quote
View Public Profile
 
Old 10-24-2010, 02:20 PM Re: pagination in php
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
The link is about pagination from an array
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-24-2010, 02:58 PM Re: pagination in php
Novice Talker

Posts: 6
Name: =)
Trades: 0
Quote:
Originally Posted by chrishirst View Post
The link is about pagination from an array
ahaa

thanks
Goal is offline
Reply With Quote
View Public Profile
 
Old 10-24-2010, 06:07 PM Re: pagination in php
Defies a Status

Posts: 1,606
Trades: 0
I don't think you need a DB to paginate an array. Though my brain is much to fried tonight to offer any useful suggestion other than searching for "pagination array".
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 10-25-2010, 11:10 PM Re: pagination in php
Novice Talker

Posts: 6
Name: =)
Trades: 0
Quote:
Originally Posted by colbyt View Post
I don't think you need a DB to paginate an array. Though my brain is much to fried tonight to offer any useful suggestion other than searching for "pagination array".
simply and easy with this tut

http://www.phpfreaks.com/tutorial/basic-pagination

thanks colbyt

thanks 4 all
Goal is offline
Reply With Quote
View Public Profile
 
Old 10-26-2010, 08:38 AM Re: pagination in php
Banned

Posts: 1
Name: Administrator
Trades: 0
Many of website use this script to alternate their table row color that selected from mysql database, very useful and cool. thanks for sharing.
seomatrix577 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to pagination in php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33715 seconds with 12 queries