0

Hi I'm new here so be gentle! ;)

I have a php form which poppulates an HTML <Select> tag with a list of approx 2500 items which consist of an id; a code and a name. The items come from a MySql database

To make it easier to use I want to be able to optionally limit the number of lines to select from based on a search criteria.

What is the best way of going about this please?

2
Contributors
4
Replies
6
Views
11 Years
Discussion Span
Last Post by AdamW
0

You would simply use the WHERE and LIMIT clauses in your MySQL select statement. For example, SELECT * from mytable; selects all rows from a table named mytable. SELECT col1, col2 from mytable; selects only the columns entitled col1 and col2 from mytable. SELECT col1, col2 from mytable WHERE col1 = 1; selects only the columns entitled col1 and col2 from records where col1 is the value 1. SELECT col1, col2 from mytable WHERE col1 = 1 LIMIT 10; does the same as the previous line only selects just the first ten records it finds, regardless of how many fulfill the WHERE criteria.

0

I need to be able to limit to a search criteria which I wont know until after the page is displayed. I can not construct the where part of the sql at the time I first need the records so I need to be able to search within the record set on the page itself in order to populate the $_Post with the record id.

Does that make sense?

0

After you retrieve a MySQL resource array, one usually loops through it to output it. Within that loop, simply use an IF clause, and only output if a particular condition is true.

0

Thanks, I ended up by using a nice little Java Script function which can be found here to filter the options

Adam

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.