Forum Moderators: coopster

Message Too Old, No Replies

Filtering an A-Z listing by a specific letter?

         

weeevil

9:53 am on Jun 5, 2007 (gmt 0)

10+ Year Member



Hi all,

I have a database, that has lots of entries, and i need to be able to filter them by a specific letter or number, what is the best way to go around this?

Cheers!

barns101

9:55 am on Jun 5, 2007 (gmt 0)

10+ Year Member



SELECT * FROM `table` WHERE `field` LIKE 'A%';
etc...

weeevil

9:59 am on Jun 5, 2007 (gmt 0)

10+ Year Member



Cheers, that would give me the desired outcome, but how would i go about giving each hyperlink (ie. [A] [B] etc.) the appropriate sql statement, keeping the existing sql statement in my recordset?

Habtom

10:56 am on Jun 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



// SELECT * FROM `table` WHERE `field` LIKE 'A%'; etc...

<a href="listpage.php?bgn=A"> [A] </a>

And on listpage.php you can have something similar to the following:

$bgnl = $_REQUEST['bgn'];
$query = "SELECT * FROM `table` WHERE `field` LIKE '". $bgnl ."%'";

If that is what you are looking for

Habtom

weeevil

11:41 am on Jun 5, 2007 (gmt 0)

10+ Year Member



at the moment, i have a page called a2z.php which has a recordset called a2z with the following query:

SELECT *
FROM films
ORDER BY STitle ASC

Now if i put this other query in that recordset, will it not overwite the existing statement? Because i have a "First" "Next" "Last" "Previous" etc navigation at the bottom, and i want to add this [A], [B] etc navigation to the top of the page.

Would i need a 2nd recordset for these, and if i do, and the user clicks on [A] will the existing navigation of page scrolling still work?

bysonary

1:46 pm on Jun 5, 2007 (gmt 0)

10+ Year Member



SELECT * FROM films WHERE STitle LIKE '".$bgnl."%' ORDER BY STitle ASC

is that not what you want?