doutangguan2460 2013-09-13 20:31
浏览 13

得到2个项而不是1个mysql数据库[关闭]

i have problem i am using below script for merge tables and get data from mysql

    $myboxexi=mysql_query('select box.id,box.page_name,box.title,box.connect,box.type,box.uid,box.description,box.image,box.url,box.status,box.date,box.time
    from boxes as box left join page_boxes as pages on box.uid=pages.uid and pages.uid="'.$session_id.'"');
    while($my_boxi=mysql_fetch_array($myboxexi)){
    $title=$my_boxi['title'];
    $bid=$my_boxi['id'];
    $ptitle=$my_boxi['page_name'];
    $connect=$my_boxi['connect'];
    $type=$my_boxi['type'];
    $iuid=$my_boxi['uid'];
    $description=$my_boxi['description'];
    $image=$my_boxi['image'];
    $url=$my_boxi['url'];
    $appr=$my_boxi['status'];
    $date=$my_boxi['date'];
    $time=$my_boxi['time'];
    $myinfo=mysql_query('select * from users where id="'.$iuid.'"');
    $my_boxi_info=mysql_fetch_array($myinfo);
    $user_id=$my_boxi_info['id'];
    $user_name=$my_boxi_info['user_name'];
    $thmb=$my_boxi_info['thumb'];
    if(strpos($thmb,'https://') !== false) {
    $thmbs=$thmb;
    }else
    {
    $thmbs='images/thumbs/'.$thmb;
    }

}

its working fine but problem is i am getting double item like if i have 1 item then i get 2 item how can i solve this issue ?

  • 写回答

3条回答 默认 最新

  • douketangyouzh5219 2013-09-13 20:35
    关注

    I think you get 2 values because you have for example,element [0] and same element with key=name of column , so use only associatif result :

    Change this :

    while($my_boxi=mysql_fetch_array($myboxexi)){
    //data here.
    }
    

    To this :

    while($my_boxi=mysql_fetch_array($myboxexi, MYSQL_ASSOC)){
    //data here.
    }
    

    Or to this

    while($my_boxi=mysql_fetch_assoc($myboxexi)){
    //data here.
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP