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
Pagination with changing textarea code on multiple pages
Old 02-22-2009, 10:47 AM Pagination with changing textarea code on multiple pages
Novice Talker

Posts: 8
Trades: 0
Hello, I am fairly new to php. I am trying to take multiple .gif images from a directory, and display them, 10 per page, with pagination. I want page number links like those on Digg or Youtube (i.e. 1 2 3 4 5...11). I also want each image displayed to link to a new page displaying the corresponding code for a user to use that image (i.e. a text area with <img src="http://image(x).gif">), without having to create multiple new pages for each individual image code. I am looking for something similar to THIS. Each image in the directory is named graphic1.gif, graphic2.gif, graphic(x).gif etc etc.

So far i have this:

PHP Code:
<?

function dirList ($directory
{

    
// create an array to hold directory list
    
$results = array();

    
// create a handler for the directory
    
$handler opendir($directory);

    
// keep going until all files in directory have been read
    
while ($file readdir($handler)) {

        
// if $file isn't this directory or its parent, 
        // add it to the results array
        
if ($file != '.' && $file != '..')
            
$results[] = $file;
    }

    
// tidy up: close the handler
    
closedir($handler);

    
// done!
    
return $results;

}

function 
file_extension($filename)
{
    
$path_info pathinfo($filename);
    return 
$path_info['extension'];
}

$totalresults dirList('animations');

$alength sizeof($totalresults);


$gifresults = array();

for(
$i=0$i<$alength$i++){
    if(
file_extension($totalresults[$i]) == "gif"){
        
$gifresults[] = $totalresults[$i];
    }
}

$number_per_page 10;

$pages ceil(sizeof($gifresults) / $number_per_page);

$current_page $_GET['p'];

for(
$i=0$i<$number_per_page$i++){
    
$x = ($current_page $number_per_page)+$i;
    echo 
"<img src=\"/graphics/animations/" $gifresults[$x] . "\" />" "<br />";
}

echo 
"<a href=\"?p=".($current_page-1)."\">Previous</a> | <a href=\"?p=".($current_page+1)."\">Next</a>";

?>
Any help is much appreciated.

Thanks.

B.
Baggy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-22-2009, 12:26 PM Re: Pagination with changing textarea code on multiple pages
Truly's Avatar
Ultra Talker

Posts: 322
Trades: 0
So where are you stuck? You seem to be heading in the right direction.

For the link back to the image, just have a unique ID number for each image. when you click on the image it can just change what its the textbox. So it would end up like www.site.com?pictureID=12345

I am not sure if that was any help, can you be more specific as to what you want help with.
__________________
DVD Movie Release Database:
Please login or register to view this content. Registration is FREE
Truly is offline
Reply With Quote
View Public Profile
 
Old 02-22-2009, 12:35 PM Re: Pagination with changing textarea code on multiple pages
Novice Talker

Posts: 8
Trades: 0
Quote:
Originally Posted by Truly View Post
So where are you stuck? You seem to be heading in the right direction.

For the link back to the image, just have a unique ID number for each image. when you click on the image it can just change what its the textbox. So it would end up like www.site.com?pictureID=12345

I am not sure if that was any help, can you be more specific as to what you want help with.
Thank you for your reply Truly. Yes, that is what I'm trying to do. I want each image to link to a new page displaying a textarea with the code for that image in it with the ID of the image changing depending on which image has been clicked on, however i don't know how to go about integrating that into my php script.

Last edited by Baggy; 02-23-2009 at 10:16 AM..
Baggy is offline
Reply With Quote
View Public Profile
 
Old 02-23-2009, 10:17 AM Re: Pagination with changing textarea code on multiple pages
Novice Talker

Posts: 8
Trades: 0
Quote:
Originally Posted by Baggy View Post
Thank you for your reply Truly. Yes, that is what I'm trying to do. I want each image to link to a new page displaying a textarea with the code for that image in it with the ID of the image changing depending on which image has been clicked on, however i don't know how to go about integrating that into my php script.
Can anyone help integrate this into my php script?

Thanks a million.
Baggy is offline
Reply With Quote
View Public Profile
 
Old 02-24-2009, 12:32 PM Re: Pagination with changing textarea code on multiple pages
Truly's Avatar
Ultra Talker

Posts: 322
Trades: 0
Well say you have a database with 10 pictures. Each movie has its own unique key, we will call this IDnum.

So on the main page you query the database and display the first 10 images. After that use a while loop and do inside do something like this

PHP Code:
echo '<a href="picdisplay.php?idnum='.$row['idnum'].'"><img src="images/'.$row['image'].'" alt="Random Picture" /></a>'
Then make a new page called picdisplay.php and use $_GET['idnum'] to find which image they clicked on and then query the database where idnum='$_GET[idnum'] and display all the information on that page.

Does that help?
__________________
DVD Movie Release Database:
Please login or register to view this content. Registration is FREE
Truly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Pagination with changing textarea code on multiple pages
 

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.22848 seconds with 12 queries