sorting alphabatically

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
Amit Mehta
Forum Newbie
Posts: 3
Joined: Tue Jun 03, 2008 7:51 am

sorting alphabatically

Post by Amit Mehta »

hi,

in my web page i want look like this.

A B C D E F G H i j k l m n o p q r s t u v w x y z show all

that means alphabetic sort when i click on "a" then only select that topic which are start with "a". and also want how to display above string (A - Z). and fetching data from data base table.

pls reply.

Thanks.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: sorting alphabatically

Post by pickle »

This is called "paging". Search for it both on these boards & Google.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
kryles
Forum Contributor
Posts: 114
Joined: Fri Feb 01, 2008 7:52 am

Re: sorting alphabatically

Post by kryles »

Code: Select all

 
 
<a href="urpage.com/script.php?sort=a">a</a>
<a href="urpage.com/script.php?sort=b">b</a>
 
 

Code: Select all

 
 
$selector = mysql_real_escape_string(trim(strip_tags($_GET['sort'])));
 
$query = "SELECT topicTitle
              FROM topicTable
              WHERE TopicTitle LIKE '".$selector."%'";
$result = mysql_fetch_row($query) or print(mysql_error());
 
while($row = mysql_fetch_row($result))
{
/* list topics here */
echo $row[0]."<br />";
}
 
 
hopefully that gives you some idea
Post Reply