Page 1 of 1

Need Help Setting Up Dynamic URL's

Posted: Sat Dec 10, 2011 3:56 pm
by nbasso713
I've been working on this for the last couple hours and haven't had much luck. Basically, every time you visit the index of my site a random image is shown. The images are stored in a directory, and i use a table to holding the id, name, and url of each image. When the index page is loaded a random int is chosen, and the id = to the int displays the corresponding url for the image.

Now i'm trying to add the id into the url, "domain.com?img=1". I also need this url to always refer to the image in row 1.

I'm pretty lost, any help is greatly appreciated.

Re: Need Help Setting Up Dynamic URL's

Posted: Mon Dec 12, 2011 9:36 am
by novice4eva
Why don't you redirect to domain.com?img=1 when the user goes to domain.com - you can check the existence of get parameter and if there is no img param redirect.

Regards,
Dee

Re: Need Help Setting Up Dynamic URL's

Posted: Mon Dec 12, 2011 10:26 am
by pickle
So every time the page is loaded, a random number is generated that maps to an image. Simply change where your number comes from. If $_GET['img'] is set, us it, otherwise generate a random number.