doufuxing8691 2012-08-22 21:56
浏览 10
已采纳

我的joomla问题离开了加入mysql

right i got this working but for some reason my loop still showing the wrong values...

$db = JFactory::getDBO();
    $query = "select * from jos_gerencia_vendas AS a LEFT JOIN jos_gerencia_clientes AS b ON b.Id=a.id_cliente where a.id_edicao = ".$iddaedicao." order by b.nomecliente ASC";

    $db->setQuery($query);
    $list = $db->loadObjectList();
    foreach ($list as $item)
            {
            $Id = $item->Id;
            $id_venda = $item->id_venda;
            $id_edicao = $item->id_edicao;
            $id_vendedor = $item->id_vendedor;
            $id_cliente = $item->id_cliente;
            $id_produto = $item->id_produto;
            $data_insercao = $item->data_insercao;
            $pagina = $item->pagina;

i need to retrieve the $Id variable from the jos_gerencia_vendas inside the foreach loop, any clue?

  • 写回答

2条回答 默认 最新

  • ds08541 2012-08-23 17:14
    关注

    You can use alias to retrieve information from the query like this

    $query = "select a.id as id,a.col1 as id_venda,a.col2 as id_edicao,b.col1 as id_vendedor from jos_gerencia_vendas AS a LEFT JOIN jos_gerencia_clientes AS b ON b.Id=a.id_cliente where a.id_edicao = ".$iddaedicao." order by b.nomecliente ASC";
    
        $db->setQuery($query);
        $list = $db->loadObjectList();
        foreach ($list as $item)
                {
                $Id = $item->Id;
                $id_venda = $item->id_venda;
                $id_edicao = $item->id_edicao;
                $id_vendedor = $item->id_vendedor;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图