Dumps Posted January 5, 2007 Share Posted January 5, 2007 I'm new to this malarky so go easy on me!I have a website with a directory of companies and their details stored in a simple MySQL table. Using the drop-down lists users can search the db by their chosen field and by an inputted value and view the list of companies matching their query. This works fine.However, I'm having problems with another more basic search method. I want users to be able to select companies using an alphabetic index ie. companies beginning with A or B etc using a row of links such as A B C D E F G H and so on. When a user selects D the companies listed will be filtered for only those beginning with D.I imagine I would first need to be able to get the value (ie. D) of the selection so I can build the sql query accordingly. Trouble is, I don't know how to do this and what to do next.Can anybody offer me any suggestions on the best way to do this? Quote Link to comment https://forums.phpfreaks.com/topic/32952-sorting-records-in-mysql-using-hyperlinks/ Share on other sites More sharing options...
Gruzin Posted January 5, 2007 Share Posted January 5, 2007 Hey Dumps,You can use something like this to pull out records begining with say: D[code]$sql = mysql_query("SELECT * FROM table WHERE filed LIKE 'D%'");[/code]Also you can add values to you links like this:[code]<option value='cat.php?id=D'>Select All Begining with D</option>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32952-sorting-records-in-mysql-using-hyperlinks/#findComment-153440 Share on other sites More sharing options...
Dumps Posted January 5, 2007 Author Share Posted January 5, 2007 Cheers, I'll give it a whirl. Quote Link to comment https://forums.phpfreaks.com/topic/32952-sorting-records-in-mysql-using-hyperlinks/#findComment-153449 Share on other sites More sharing options...
Dumps Posted January 8, 2007 Author Share Posted January 8, 2007 I don't think the suggestion given is quite what I had in mind. Rather than using option buttons or a drop down list I want the user to be able to select a letter exactly the same way as you would select a hyperlink and filter the records according to what the user selected.So the page would have a list of letters across the top;A B C D E F G and so on When a user selects the letter by clicking on it the query is run and the records filter accordingly. These would be hyperlinks - wouldn't they?Any help gratefully appreciated... Quote Link to comment https://forums.phpfreaks.com/topic/32952-sorting-records-in-mysql-using-hyperlinks/#findComment-156040 Share on other sites More sharing options...
Jessica Posted January 8, 2007 Share Posted January 8, 2007 Have the link have the letter on the end .php?letter=aThen use $_GET['letter'] to get the letter to put in your SQL. Quote Link to comment https://forums.phpfreaks.com/topic/32952-sorting-records-in-mysql-using-hyperlinks/#findComment-156043 Share on other sites More sharing options...
Dumps Posted January 8, 2007 Author Share Posted January 8, 2007 Marvellous. Quote Link to comment https://forums.phpfreaks.com/topic/32952-sorting-records-in-mysql-using-hyperlinks/#findComment-156188 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.