What is the correct way to set up a select list with options from a MySQL table?
What is the correct way to set up a select list with options from a MySQL table?
rmeetin
Posts: 100Questions: 24Answers: 1
It is straight-forward to create a select list from a couple static options like:
label: 'Publish:',
name: 'publish',
type: "select",
options: [
{ label: "Yes", value: "Yes" },
{ label: "No", value: "No" }
]
},
How do you do this to create the option list from data stored in a table? Categories for instance?
$query = "select id, name from product_categories order by name asc";
I figured out a very hacky way to do this by adding a query into the html file and manually setting up the options in a variable like:
label: 'Category:',
name: "catid",
type: "select",
multiple: true,
separator: ":",
options: [
<?php echo $catids; ?>
]
},
What is the right way to do this?
This discussion has been closed.
Answers
Hi @rmeetin ,
This thread should help, it's asking the same thing.
Cheers,
Colin