I have form with a number of drop boxes which have the numbers 1-5 in them. I can use this code to populate a drop down but was wondering if I can somehow only make the call to
Saving as a string would save you the processing of having to loop through the same data generating the same output multiple times. If this is what you want, you could do the following.
Replace:
echo '
with:
$drop = '';
Then you can echo $drop
several times if you want.
If for whatever reason you want different select attributes, you could just save the options list and print the select around that, like this:
$dropOptions = "";
while($row = $result->fetch_assoc()){
$dropOptions .= '';
}
Then just echo '