I am using a dropdown box to perform a selection in a form.
I have 4 values (‘value1′,’value2′,’value3′,’value4’). Each are listed in the dropdown box. But I also want an option for all 4 values for example, here is the array I am currently using for the function that draws my dropdown menu:
$menuValues("'value1','value2','value3','value4'",'value1','value2','value3','value4');
This however produces an empty variable on the action page. I need to retain the single quotes around each value to feed a function that in turn drives a mysql query. Which is why I have used double-quotes to enclose the first value.
This is the dropdown function:
function frDrop($arr,$frm,$dropTitle) {
echo "<select name='".$frm."' id='".$frm."'><option value=''>".$dropTitle."...</option>";
foreach ($arr as $key => $value) {
echo "<option value='".$value."'>".$value."</option>";
}
echo "</select>";
}
It is not clear where is function frDrop() called and what does it’s argument mean. But for my answer below, I’m assuming that $arr is the array that contains the dropdown options. So,
Now, as I’ve guessed in my comment above, perhaps the single-quotes in the first array value – “‘value1′,’value2′,’value3’,’value4′” – is conflicting with the single quotes in the tag in the foreach() in function frDrop(). This is how the tag will look like for the first value:
You might try to escape the single quotes like this:
OR, instead use single quotes to enclose your PHP statement:
Hope this helps.