dtjpnd7517 2010-05-04 08:05
浏览 39
已采纳

在php中优先打印数组值

I have country table,

i fetch all values and moved into array ,

these value i like to populate into combo/dropdown list ,

here i want to do some magic things,

that is , for my site most of the users coming from uk,us,Australia,Romain and few,

So i like to populate by my preference ,

is there any array will do this magic work, else is it possible mysql query ,

So final question is ,

Populate country name into combo based on my prefernce ,

Thanks

  • 写回答

2条回答 默认 最新

  • dou1908 2010-05-04 08:22
    关注

    It's very annoying to have a country list where not all items can be found at their alphabetical position. I suggest you just duplicate the top 2 or 3 more used items and show them at the top of the complete list:

    Australia
    United Kingdom
    United States
    ---------------
    Afghanistan
    Albania
    Australia
    Austria
    ...
    

    I'm not sure, though, why you think this involves any sort of magic. You could accomplish this by adding a new weight column to the country table in your database that defaults to e.g. 1 and increment it to larger values for items you want to highlight. You can then build your data in PHP or in SQL.

    SELECT country_id, country_name
    FROM country
    WHERE weight>1
    ORDER BY weight, country_name
    UNION ALL
    SELECT country_id, country_name
    FROM country
    ORDER BY country_name
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构