Efficient?
Posted: Tue Dec 26, 2006 2:14 pm
Hi,
Seasonal greeting to one and all!
I have a few lines of code which I think could be a little more efficient:
It is some code I am using on an image gallery. An image is dispalyed with a 'back' and 'next' link to view the next or previous image. Easy enough but I also have the images in two different resolutions. The bigger sized images are in the default location '/' and the smaller ones are in a folder '/small'.
So if the user is viewing small images, when they click next they should view the subsequent image in the smaller format too hence the variable 'size'.
At present it does work but I am sure I have over complicated the code above.
Any suggestions would be appreciated.
Thanks,
Rob.
Seasonal greeting to one and all!
I have a few lines of code which I think could be a little more efficient:
Code: Select all
session_start();
if($_GET['size']=='small'){
$_SESSION['size']='/small';
}
if($_GET['size']=='large'){
unset($_SESSION['size']);
}
if(isset($_SESSION['size'])){
$size=$_SESSION['size'];
}
else{
$size='/';
unset($_SESSION['size']);
}It is some code I am using on an image gallery. An image is dispalyed with a 'back' and 'next' link to view the next or previous image. Easy enough but I also have the images in two different resolutions. The bigger sized images are in the default location '/' and the smaller ones are in a folder '/small'.
So if the user is viewing small images, when they click next they should view the subsequent image in the smaller format too hence the variable 'size'.
At present it does work but I am sure I have over complicated the code above.
Any suggestions would be appreciated.
Thanks,
Rob.