Page 1 of 1

Sorting my links in order!!!

Posted: Sat Mar 27, 2004 5:29 am
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)

Posted: Sat Mar 27, 2004 1:05 pm
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...

Posted: Sat Mar 27, 2004 6:31 pm
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.