Sorting my links in order!!!

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
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Sorting my links in order!!!

Post by Joe »

Recently I have been thinking of developing a script that allows you to choose any letter in the alphabet from A to Z to display the links beginning with that letter. The only problem is that I do not have a clue on how to request the users choice. I was told something about using GET. Please help?

Regards


Joe 8)
Goowe
Forum Commoner
Posts: 94
Joined: Mon Mar 15, 2004 9:51 am
Location: Southeast Alaska

Post by Goowe »

I think you'd have to manually type out the letters A-Z and have them link to something such as index.php?sort=a&by=asc

The next part I wouldn't be sure on how to go about, there is probably a better way than what I'm thinking... but....

Use strlen() to count the characters of the url name, then use substr() to subtract all the characters except the first one and do an if() statement saying that if that first character is equal to $_GET['sort'] then display it, otherwise don't mess with it :roll:

Hope this helps, I could code it up if you want a better example...
Bennettman
Forum Contributor
Posts: 130
Joined: Sat Jun 15, 2002 3:58 pm

Post by Bennettman »

GET is the name for variables sent as part of the URL:

for example: http://site.com/page.php?id=4&name=Moo

sends the following info:
$_GET['id'] = 4;
$_GET['name'] = "Moo";

If register_globals is on, then:
$id = 4;
$name = "Moo";

So, you could make something that ends up sending the user to something like links.php?letter=A and then you have $_GET['letter'] set as A so you use that in the script to get the right links.
Post Reply