我想知道是否可以将同一个表中不同字段的数据放入select选项或php中的combobox中。我将附上下表
mysql> select * from item;
+----------+--------------+-----------------------------------------------------------------------+-----+--------+----------+--------+
| itemcode | modelnum | item_abb | qty | price | spcredit | spcash |
+----------+--------------+-----------------------------------------------------------------------+-----+--------+----------+--------+
| 2 | P9269-12+6BH | Scholer Ma. Theresa Chandelier 2Layers w/ Maroon Crystals 12+6L DK CH | 2 | 230000 | 138000 | 115000 |
| 4 | P9269-12+6CH | Scholer Ma. Theresa Chandelier 2Layers w/ Blue Crystals 12+6L CH | 0 | 230000 | 138000 | 115000 |
| 5 | P9344-8BH | Scholer Ma. Theresa Chandelier w/ Maroon Crystals DK CH | 1 | 90000 | 54000 | 45000 |
+----------+--------------+-----------------------------------------------------------------------+-----+--------+----------+--------+
3 rows in set (0.00 sec)
例如Scholer Ma。 Theresa Chandelier 2Layers w / Maroon Crystals 12 + 6L DK CH它的价格将在230000,138000和115000中选择。
答案 0 :(得分:1)
这应该创建一个包含不同选项的下拉列表
echo '<select>
<option>' . $result['price'] . '</option>
<option>' . $result['spcredit'] . '</option>
<option>' . $result['spcash'] . '</option>
</select>';
DEMO: https://eval.in/772959
答案 1 :(得分:0)
使用CONCAT mysql功能
select item_abb, CONCAT(price, ", ",spcredit, ", ",spcash) as price from item;