Populate more than one drop down using the same mysql query

前端 未结 3 663
礼貌的吻别
礼貌的吻别 2021-01-25 07:14

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

3条回答
  •  囚心锁ツ
    2021-01-25 07:20

    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 '

    提交评论

提交回复
热议问题