Is there a way that I can use a single sql statement to select a variable number of columns and output those selections into an array?
For instance, I have a form that allows users to select from a database information that they may be interested in. They may be interested in one item, they may be interested in ten.
If the user were interested in two items, it might look like:
$sql="select item1, item2, from table where....
Whereas, if the user selected four items, that same select statement would look like:
$sql="select item1, item2, item3, item4 from table where...
I could load the selections into an array, but I don’t know how to dynamically change the SQL statement. I could count the number of items in the array, and then do an if/else statement to cover all the data that might be asked for (up to 12 different columns, so that seems like a lot of code for something like this).
Thanks in advance for the help.