GetDotted Domains

Viewing Thread:
"PHP Help"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Thu 14/04/05 at 15:03
Regular
Posts: 4,279
Is there a way to set a range for url variables?

eg

index.php?img=0

I want img to go from 0 - 10. Any way to do this?
Thu 14/04/05 at 16:40
Regular
Posts: 4,279
Ok, thanks alot for the help guys.

EDIT: Works a treat.

Now to add a file count that will determine the maximum number of images. Don't tell me though, I'm learning :P
Thu 14/04/05 at 16:39
Regular
"NULL"
Posts: 1,384
Damarus wrote:
> Nimco wrote:
> Or use an if statement to display the previous and next buttons in
> the
> first place - like I do on my galleries.
>
> I was going to do something like this however my script already uses
> php in the link.
>
> > border="0">
>
>
> Would it be possible to do php including php. IE.
>
> >
> if(etc)
>
> echo (' above code ');
>
> ?>

Yup, nothing wrong with that at all - that's what PHP is for!





Thu 14/04/05 at 16:36
Regular
Posts: 4,279
Nimco wrote:
> Or use an if statement to display the previous and next buttons in the
> first place - like I do on my galleries.

I was going to do something like this however my script already uses php in the link.




Would it be possible to do php including php. IE.


if(etc)

echo (' above code ');

?>
Thu 14/04/05 at 16:31
Regular
"NULL"
Posts: 1,384
Or use an if statement to display the previous and next buttons in the first place - like I do on my galleries.
Thu 14/04/05 at 16:30
Regular
"Lisan al-Gaib"
Posts: 7,093
Damarus wrote:
> At the minute I have an image with previous and next commands.
>
> This all works very well, however the problem I'm having is that
> images -1 and 5 don't exist.
>
> Pressing next will add 1 to "img" and pressing previous
> will deduct 1 from "img".
>
> Obviously, I don't want it to display pics that don't exist.

So on variable pickup do a check?

if ($var < 0) $var = 0;
if ($var > 10) $var = 10;

Dunno what you mean by image 5.

Ahhhh. Get you. I think it'll be impossible to do via html variable passing only, you've have to do a SQL statement and get the next / previous image that exists from your database. You could try to load the image and if there's no data, add on to / subtract from the variable and reload that page, but that's an ugly, ugly solution.
Thu 14/04/05 at 16:26
Regular
Posts: 4,279
At the minute I have an image with previous and next commands.

This all works very well, however the problem I'm having is that images -1 and 5 don't exist.

Pressing next will add 1 to "img" and pressing previous will deduct 1 from "img".

Obviously, I don't want it to display pics that don't exist.
Thu 14/04/05 at 15:51
Regular
"Pouch Ape"
Posts: 14,499
You want to limit the variable to between 0 and 10?

if($img >= 0 && $img <= 10)
{ echo "True"; }
else
{ echo "False"; }
Thu 14/04/05 at 15:51
Regular
"Lisan al-Gaib"
Posts: 7,093
Nimco wrote:
> so if you went to: index.php?img=3-8
>
> it would display a page with:
>
> low = 3
> high = 7
> ----------------
>
> Are either of those what you are looking for?

low = 3
high = 8
----------------

Don't try to say my code is bugged. ;)
Thu 14/04/05 at 15:46
Regular
"NULL"
Posts: 1,384
I'm still not following exactly what you're trying to do. My script will just write:

index.php?img=0
index.php?img=1
index.php?img=2
index.php?img=3
index.php?img=4
index.php?img=5
index.php?img=6
index.php?img=7
index.php?img=8
index.php?img=9
index.php?img=10

whereas with Pandaemonium's script will turn a query string variable into the two limits of a range, so if you went to: index.php?img=3-8

it would display a page with:

low = 3
high = 7
----------------

Are either of those what you are looking for?
Thu 14/04/05 at 15:32
Regular
"Lisan al-Gaib"
Posts: 7,093
Appallingly quick and dirty, and there's probably a far better way to do it, but I think this is what you're looking for.

[edit] If anyones got an easier way to do this, I'd be interested. Nuts to passing arrays mind.

test.php

-=-=-=-=-=-=-=-=-=-

if (isset($HTTP_GET_VARS['img'])) {
$range = ($HTTP_GET_VARS['img']);
$split = strpos($range,"-");
$low = substr($range,0,$split);
$high = substr($range,$split+1,strlen($range));
echo "low = ".$low;
echo "
high = ".$high;
echo "
-------------------
";
}
?>



Test




Link

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Excellent support service!
I have always found the support staff to provide an excellent service on every occasion I've called.
Ben
My website looks tremendous!
Fantastic site, easy to follow, simple guides... impressed with whole package. My website looks tremendous. You don't need to be a rocket scientist to set this up, Freeola helps you step-by-step.
Susan

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.