Hi there - I have an array of topics and a sql query that pulls out a series of subject topics related to a course in my database.
I want to create a select box that contains that array of topics and then sets to Selected each of those that match the resultset. The aim is that this will allow an editor to show which topics a course is assigned too and I can then select more or deselect current ones.
any ideas would be great
cheers
frank
Pattern matching a mysql result with an array
Moderator: General Moderators
-
sleazyfrank
- Forum Commoner
- Posts: 40
- Joined: Fri Aug 19, 2005 3:59 am
- Location: Horsham, West Sussex
Put the results of your query in an array. Then, when you're looping through your array of topics, call in_array() and if it returns true, set that topic to selected.
Remember that you have to set the `multiple` property in order to have multiple options selectable.
Remember that you have to set the `multiple` property in order to have multiple options selectable.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.