Need Help Setting Up Dynamic URL's

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nbasso713
Forum Commoner
Posts: 29
Joined: Fri Nov 04, 2011 7:51 am

Need Help Setting Up Dynamic URL's

Post 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.
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: Need Help Setting Up Dynamic URL's

Post 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
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Need Help Setting Up Dynamic URL's

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply