Jump to content

Recommended Posts

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?
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]
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...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.