Page 1 of 1

Pattern matching a mysql result with an array

Posted: Mon Oct 31, 2005 11:16 am
by sleazyfrank
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

Posted: Mon Oct 31, 2005 12:15 pm
by pickle
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.