[Fwd: Re: [PHP] previous + next buttons, no DB]

2005-08-18 Thread [EMAIL PROTECTED]

if you have all images in one directory and ONLY images in that folder

you can try something like this:

  $path = '/path/to/directory/with/images';
  $handle = opendir($path);
  while (false != ($file = readdir($handle)))
  {
   if ($file != "." && $file != ".." && !ereg('.php', $file))
#excluding . and .. files and php file with this code

  {
  $images[] = $file;
  }
  }
  closedir($handle);

  $last = count($images);
  foreach($images as $key => $value)
  {
 swtich($key)
 {
 case (0):
   echo '[ next ]';
   break;
 case ($last):
   echo '[ prevous ]';
   break;
 default:
   echo '[ previous ] [ next ]';
   break;
  }
  }


I hope this will help
;)

-afan

Ashley M. Kirchner wrote:



   I have a client that maintains picture galleries by simply dropping 
images into a directory.  I have a template created that when loaded, 
with a specific $ID, will load the image that corresponds to that 
$ID.  The request now is to have previous and next buttons that web 
surfers can click on to cycle through the rest of the images in the 
directory (instead of having to close that pop-up and click on another 
image to look at.)


   What's the best way to go about this?  Since I don't have a list of 
images in any kind of array (such as a result from  DB query), I'm a 
bit at a loss here.  Obviously if someone clicks on the first image on 
the gallery page, it should only have a 'next' button, and if they 
click the last image, it should only have a 'previous' button, but 
anything else on the page should have a 'previous' and 'next' button.  
I just don't know how to keep that relationship or how to start coding 
that.


   Ideas/suggestions/pointers are much appreciated here.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] previous + next buttons, no DB

2005-08-18 Thread Greg Donald
On 8/18/05, Ashley M. Kirchner <[EMAIL PROTECTED]> wrote:
> Since I don't have a list of
> images in any kind of array (such as a result from  DB query)

Sure you do.

#!/usr/bin/php
read() ) )
{
  $a[] = $e;
}
$d->close();
print_r( $a );

?>


-- 
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] previous + next buttons, no DB

2005-08-18 Thread Ashley M. Kirchner


   I have a client that maintains picture galleries by simply dropping 
images into a directory.  I have a template created that when loaded, 
with a specific $ID, will load the image that corresponds to that $ID.  
The request now is to have previous and next buttons that web surfers 
can click on to cycle through the rest of the images in the directory 
(instead of having to close that pop-up and click on another image to 
look at.)


   What's the best way to go about this?  Since I don't have a list of 
images in any kind of array (such as a result from  DB query), I'm a bit 
at a loss here.  Obviously if someone clicks on the first image on the 
gallery page, it should only have a 'next' button, and if they click the 
last image, it should only have a 'previous' button, but anything else 
on the page should have a 'previous' and 'next' button.  I just don't 
know how to keep that relationship or how to start coding that.


   Ideas/suggestions/pointers are much appreciated here.

--
R | I haven't lost my mind; it's backed up on tape somewhere.
 +
 Ashley M. Kirchner    .   303.442.6410 x130
 IT Director / SysAdmin / WebSmith . 800.441.3873 x130
 Photo Craft Laboratories, Inc.. 3550 Arapahoe Ave. #6
 http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] << Previous / Next Buttons >>

2001-09-10 Thread Michael O'Neal

on 9/6/01 11:52 PM, [EMAIL PROTECTED] went and wrote:

> I'll show you what I did but realize I'm an advanced beginner/intermediate
> programmer. This may not be the most efficient way to do it but seems to
> be the simplest code compared to other ways of doing it that I've seen. Not
> sure if I will explain this well enough either. And this is for a fairly small
> database. With a larger one it may be too inefficient.
> 
> First count how many records are in the database for the album and put
> it in $count.
> 
> Then loop through all the records in the album, place the id for each record
> in an array and find out where in the array the current record is. $photo_id
> is fed to this script which tells it which picture to display:
> 
> $x = 0;
> while ($row = mysql_fetch_array($result)) {
> $photo_id1 = $row['photoid'];
> $array[$x] =  $photo_id1;
> if ($photo_id1 == $photo_id) {
> $position = $x;

Thanks a lot, Jeff & Chris.  I'll try it this morning!


mto

-- 

Michael O'Neal
Web Producer/ Autocrosser
ST 28 '89 Civic Si
-
 M   A   N   G   O
B  O  U  L  D  E  R
-
http://www.thinkmango.com
e- [EMAIL PROTECTED]
p- 303.442.1821
f- 303.938.8507


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] << Previous / Next Buttons >>

2001-09-06 Thread Chris Lee

I just use LIMIT its alot better, alot less CPU intensive.

if (!isset($pos))
$pos = 0

SELECT * FROM product LIMIT 0, $pos

$pos++
if ( !((SELECT count(*) FROM product) > $pos) )
Next

you get the idea.

  Chris Lee
  [EMAIL PROTECTED]

"Jeff Oien" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Hi, what's the simplest way to provide previous/next buttons that
navigate
> > through individual records of a database?  This is for a photo gallery,
so I
> > want to do one record at a time until I'm out of records, then I want
the
> > "next" button to disappear.  I've been fiddling with it for a while now,
but
> > haven't been very successful.  Anyone have any snippets, or ideas for
me?
> >
> > Thanks in advance.
>
> I'll show you what I did but realize I'm an advanced beginner/intermediate
> programmer. This may not be the most efficient way to do it but seems to
> be the simplest code compared to other ways of doing it that I've seen.
Not
> sure if I will explain this well enough either. And this is for a fairly
small
> database. With a larger one it may be too inefficient.
>
> First count how many records are in the database for the album and put
> it in $count.
>
> Then loop through all the records in the album, place the id for each
record
> in an array and find out where in the array the current record is.
$photo_id
> is fed to this script which tells it which picture to display:
>
> $x = 0;
> while ($row = mysql_fetch_array($result)) {
> $photo_id1 = $row['photoid'];
> $array[$x] =  $photo_id1;
> if ($photo_id1 == $photo_id) {
> $position = $x;
> }
> $x++;
> }
>
> In another sql query for retrieving the specific image (have to compensate
for
> array[] starting at zero but record count starting at 1):
>
> $row = mysql_fetch_array($result);
> $photo_id = $row['photoid'];
> if ($position == 0) {
> $photo_pos = $position + 1;
> echo "Showing $photo_pos of $count << Previous"; //no link
> }
> else {
> $photo_pos = $position + 1;
> $previous_pos = $photo_pos - 2;
> $previous = $array[$previous_pos];
> echo "Showing $photo_pos of $count  href=\"display.php?photo_id=$previous\"><< Previous";
> }
> if ($count == $photo_pos) {
> echo " | Next >>"; //no link
> }
> elseif ($photo_pos < $count) {
> $next_pos = $photo_pos;
> $next = $array[$next_pos];
> echo " |  href=\"display.php?photo_id=$next\">Next >>";
> }
>
> Comments from more experienced programmers welcome. I don't want to lead
> astray.
> Jeff Oien



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] << Previous / Next Buttons >>

2001-09-06 Thread Jeff Oien

> Hi, what's the simplest way to provide previous/next buttons that navigate
> through individual records of a database?  This is for a photo gallery, so I
> want to do one record at a time until I'm out of records, then I want the
> "next" button to disappear.  I've been fiddling with it for a while now, but
> haven't been very successful.  Anyone have any snippets, or ideas for me?
> 
> Thanks in advance.

I'll show you what I did but realize I'm an advanced beginner/intermediate 
programmer. This may not be the most efficient way to do it but seems to
be the simplest code compared to other ways of doing it that I've seen. Not
sure if I will explain this well enough either. And this is for a fairly small 
database. With a larger one it may be too inefficient.

First count how many records are in the database for the album and put
it in $count.

Then loop through all the records in the album, place the id for each record
in an array and find out where in the array the current record is. $photo_id
is fed to this script which tells it which picture to display:

$x = 0;
while ($row = mysql_fetch_array($result)) {
$photo_id1 = $row['photoid'];
$array[$x] =  $photo_id1;
if ($photo_id1 == $photo_id) {
$position = $x;
}
$x++;
}

In another sql query for retrieving the specific image (have to compensate for
array[] starting at zero but record count starting at 1):

$row = mysql_fetch_array($result);
$photo_id = $row['photoid'];
if ($position == 0) {
$photo_pos = $position + 1; 
echo "Showing $photo_pos of $count << Previous"; //no link
}
else {
$photo_pos = $position + 1; 
$previous_pos = $photo_pos - 2;
$previous = $array[$previous_pos];
echo "Showing $photo_pos of $count << Previous";
}
if ($count == $photo_pos) {
echo " | Next >>"; //no link
}
elseif ($photo_pos < $count) {
$next_pos = $photo_pos;
$next = $array[$next_pos];
echo " | Next >>";
}

Comments from more experienced programmers welcome. I don't want to lead
astray.
Jeff Oien

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] << Previous / Next Buttons >>

2001-09-06 Thread Jack Dempsey

http://www.phpbuilder.com/columns/rod2221.php3

jack

-Original Message-
From: Michael O'Neal [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 06, 2001 12:41 PM
To: "Php-General@Lists. Php. Net"
Subject: [PHP] << Previous / Next Buttons >>


Hi, what's the simplest way to provide previous/next buttons that navigate
through individual records of a database?  This is for a photo gallery, so I
want to do one record at a time until I'm out of records, then I want the
"next" button to disappear.  I've been fiddling with it for a while now, but
haven't been very successful.  Anyone have any snippets, or ideas for me?

Thanks in advance.


mto

--

Michael O'Neal
Web Producer/ Autocrosser
ST 28 '89 Civic Si
-
 M   A   N   G   O
B  O  U  L  D  E  R
-
http://www.thinkmango.com
e- [EMAIL PROTECTED]
p- 303.442.1821
f- 303.938.8507


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] << Previous / Next Buttons >>

2001-09-06 Thread Michael O'Neal

Hi, what's the simplest way to provide previous/next buttons that navigate
through individual records of a database?  This is for a photo gallery, so I
want to do one record at a time until I'm out of records, then I want the
"next" button to disappear.  I've been fiddling with it for a while now, but
haven't been very successful.  Anyone have any snippets, or ideas for me?

Thanks in advance.


mto

-- 

Michael O'Neal
Web Producer/ Autocrosser
ST 28 '89 Civic Si
-
 M   A   N   G   O
B  O  U  L  D  E  R
-
http://www.thinkmango.com
e- [EMAIL PROTECTED]
p- 303.442.1821
f- 303.938.8507


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]