duandong1963 2015-06-17 07:50
浏览 31
已采纳

如何一次插入所有下拉记录?

I have a huge number of records in a drop-down box(approximately 27000 or more).

HTML -

<select name="manufacturer" id="manufacturer">
    <option value="">Select a Builder</option>
    <option value="1-hull">#1 Hull</option>
    <option value="49er">49er</option>
    <option value="a-m-f">A M F</option>
    <option value="a-m-manufacturing">A&amp;M Manufacturing</option>
    <option value="a1-custom-trailers">A1 Custom Trailers</option>
     - -    -    -  -      -
     -     -   -    -   -  -
    <option value="zuma">Zuma</option>
</select>

Above drop-down I collect this data from different website. I want to put in my own website with dynamic content. I have tried to insert one by one it is not possible to insert all record in single handed. So I want to any shortcut method for insert all these text in my MySQL database table. I need option inner HTML text will inserting into my database table.

If I will get all the option text in an Array then easily I can manage it. But I am confused how to get all text in Array by using PHP code.

  • 写回答

2条回答 默认 最新

  • dtutlamjasblef7982 2015-06-17 07:56
    关注

    Here's a solution with preg_match_all

    <?php
    
    $string = '<option value="">Select a Builder</option>
        <option value="1-hull">#1 Hull</option>
        <option value="49er">49er</option>
        <option value="a-m-f">A M F</option>
        <option value="a-m-manufacturing">A&amp;M Manufacturing</option>
        <option value="a1-custom-trailers">A1 Custom Trailers</option>
        <option value="zuma">Zuma</option>
    ';
    
    preg_match_all('/>(.*?)<\//',$string,$matches);
    
    var_dump($matches[1]);
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失