dou11655853 2015-04-28 02:49
浏览 33
已采纳

数组值标签?

i have an array (Car, SUV, Truck, Bike) that's used in a form. when the option is selected the value is saved to the customers account in database. Value is the array position (eg: 0, 1, 2, 3).

I want this info to be displayed on another page in a table using php as i'm using magento. Currently it only displays the database saved value (0,1,2,3), but i want it to show as ((Car, SUV, Truck, Bike). How do i do this?

i need a way to make it know that 0=Car, 1=SUV, 2=Truck, 3=Bike)

heres what the table looks like now: enter image description here

The make column represents the vehicle manufacturer (toyota, honda, etc)and type represents (car, bike, suv)

Please help!

  • 写回答

1条回答 默认 最新

  • duangu4943 2015-04-28 04:08
    关注

    Make the table field type an enum that matches the array you specified.

    More Details

    An ENUM data type is an array that maps a key to a value. If you change the column type to an enumeration, then your Database will display an human readable value instead of a number (e.g., Car, SUV, Truck, Bike).

    Also, you can interact with the enum using the Key or the Value so you shouldn't have to change your current implementation.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探