[PHP] Re: Replacing datafile with array

2001-09-18 Thread _lallous

works like a charm

just initializet the $retVal function...

$retVal = array();
rest of script here

Daniel alsén [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi,

 i am trying to replace a datafile wich contains the contents of a
directory
 with an array.
 I am reading the directory and am trying to pass the value to an array.
What
 am i doing wrong? Shouldn´t $retVal contain the direcory info?

 Also, is there a way to use the content of an array without getting the
word
 'Array' at the start?

 $handle=opendir('.');
 while (false !== ($file = readdir($handle)))

 if ($file != .  $file != ..  ereg(.jpg,$file)) {

 $retVal[count($retVal)] = $file;

 }

 # Daniel Alsén| www.mindbash.com #
 # [EMAIL PROTECTED]  | +46 704 86 14 92 #
 # ICQ: 63006462   |  #




-- 
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] Re: Replacing datafile with array

2001-09-18 Thread Daniel Alsén

Hmm...

it still doesn´t work.

If i echo $retVal i just get the word 'Array' (the same number of times that
the number of files in the directory).

If i echo $file i get the file listing...however, it doesn´t pass on the
content to the rest of my script.

Maybe someone could help me out with the whole script? I downloaded this
from some script archive and it works if i use the list.photos datafile. But
i don´t want to change that file every time a new photo is uploaded.
I am trying to read the directory and use the directory handle listing
instead.

If anyone wants to help me out making this databasedriven instead youre very
welcome :)

?PHP

$retVal = array ();
//Load Directory Into Array
$handle=opendir('.');
while (false !== ($file = readdir($handle)))

if ($file != .  $file != ..  ereg(.jpg,$file)) {

$retVal [count($retVal)] = $file;

echo $retVal br\n;

}

//initialize variables
//$data_file = list.photos;
$thumbnail_dir = thumbs/;
$num_rows = 3;
$photos_per_row = 3;
$photos = file($retVal);  //$retVal used to be $data_file
$total_photos = sizeof($photos);
$photos_per_page = $num_rows * $photos_per_row;
//check to see if the start variable exists in the URL.
//If not, then the user is on the first page - set start to 0
if(!isSet($start)){
$start = 0;
}
//init i to where it needs to start in the photos array
$i = $start;
$prev_start = $start - $photos_per_page;
$next_start = $start + $photos_per_page;


for ($row=0; $row  $num_rows; $row++){
  print(tr\n);
  for ($col=0; $col  $photos_per_row; $col++){
  if($i  $total_photos){
$thumbnail = $thumbnail_dir.trim($photos[$i]);
$thumb_image_size = getimagesize($thumbnail);
$image_size = getimagesize(trim($photos[$i]));
print(td align=\center\
a
href=\javascript:photo_open('photo_display.php?photo=.trim($photos[$i]).'
,'.$image_size[0].','.$image_size[1].');\img src=\.$thumbnail.\
.$thumb_image_size[3]. border=\0\/a/td\n);
  } else {
print(td/td\n);
  }
  $i++;
}
print(/tr\n);
}


//Clean up directory array
closedir($handle);
return $retVal;


//end table
?

 -Original Message-
 From: _lallous [mailto:[EMAIL PROTECTED]]
 Sent: den 18 september 2001 13:46
 To: [EMAIL PROTECTED]
 Subject: [PHP] Re: Replacing datafile with array


 works like a charm

 just initializet the $retVal function...

 $retVal = array();
 rest of script here


-- 
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] Re: Replacing datafile with array II

2001-09-18 Thread Daniel Alsén

Woops!

I actually got the listing to work by replacing $photos = file($retVal);
with $photos = $retVal; :)

But, there´s still a problem. The script doesn´t seem to be able to use the
navigation part (print out the next and previous links). That part of the
script looks like this:

?PHP
//print out navigation links
if(($start == 0)  ($next_start  $total_photos)){

//you're at the beginning of the photo gallery

?

  font face=arial, helvetica size=2b
  a href=galleri.php?start=?PHP print($next_start);?next page/a
  /font/b


?PHP
}
elseif (($start  0)  ($next_start  $total_photos)){

//you're in the middle of the photo gallery

?

  font face=arial, helvetica size=2
  bfont color=#FF#171;/font
  a href=galleri.php?start=?PHP print($prev_start); ?prev
page/a/b/font
  b|/b
  font face=arial, helvetica size=2
  ba href=galleri.php?start=?PHP print($next_start); ?next page/a
font
  color=#FF#187;/font/b/font

?PHP
}
elseif(($start == 0)  ($next_start  $total_photos)){

//you're in a photo gallery with only one page of photos

?

?PHP
}
else {

//you're at the end of the photo galley

?
  font face=arial, helvetica size=2
  bfont color=#FF#171;/font
  a href=galleri.php?start=?PHP print($prev_start); ?prev
page/a/b/font
?PHP
}
?

 -Original Message-
 From: _lallous [mailto:[EMAIL PROTECTED]]
 Sent: den 18 september 2001 13:46
 To: [EMAIL PROTECTED]
 Subject: [PHP] Re: Replacing datafile with array


 works like a charm

 just initializet the $retVal function...

 $retVal = array();
 rest of script here

 Daniel alsén [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Hi,
 
  i am trying to replace a datafile wich contains the contents of a
 directory
  with an array.
  I am reading the directory and am trying to pass the value to an array.
 What
  am i doing wrong? Shouldn´t $retVal contain the direcory info?
 
  Also, is there a way to use the content of an array without getting the
 word
  'Array' at the start?
 
  $handle=opendir('.');
  while (false !== ($file = readdir($handle)))
 
  if ($file != .  $file != ..  ereg(.jpg,$file)) {
 
  $retVal[count($retVal)] = $file;
 
  }
 
  # Daniel Alsén| www.mindbash.com #
  # [EMAIL PROTECTED]  | +46 704 86 14 92 #
  # ICQ: 63006462   |  #
 



 --
 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]




RE: [PHP] Re: Replacing datafile with array Sorry... .)

2001-09-18 Thread Daniel Alsén

Sorry,
It seems like every time i posted a question i was able to solve it myself
:) Something strange going on in my problem solving part of the brain.

I got the whole script to work. The navigation part solved itself when i
moved the 'cleaning up' part to the very end of the script.

Still, if anyone wants to help out, or has a good solution, to make this
databasedriven - please e-mail me.

Regards
# Daniel Alsén| www.mindbash.com #
# [EMAIL PROTECTED]  | +46 704 86 14 92 #
# ICQ: 63006462   |  #


-- 
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]