doutiaosu2310 2012-11-28 16:03
浏览 38
已采纳

php - print_r()包含一组数据

Working in Joomla, I have my model and view set up, but when the page is loaded, no data appears.

Model:

class mlsModelmls extends JModel
{
/**
 * Gets the info
 */
function mlsdata($column)
    {
    $db =& JFactory::getDBO();
    $query = "
      SELECT *
        FROM ".$db->nameQuote('#__mls')."
        WHERE ".$db->nameQuote('MSTMLSNO')." = ".$db->quote('4112065').";
    ";
    $db->setQuery($query);
    $row = $db->loadRow();
    print_r($row[$column]);
    }
}

View:

class mlsViewmls extends JView
{
function mlsnum($tpl = null)
    {
    $model = &$this->getModel();
    $mlsnum = $model->mlsdata(MSTMLSNO);
    $this->assignRef( 'mlsnum', $mlsnum );

    $agentuid = $model->mlsdata(MSTLISTBRD);        
    $this->assignRef( 'agentuid', $agentuid );

    $listdt = $model->mlsdata(MSTLISTDT);       
    $this->assignRef( 'listdt', $listdt );

          /** Some more assignRef() */

    parent::display($tpl);
    }
}

TMPL:

<h2 class="price">
    <?php echo $this->mlsnum; ?>
</h2>

When the page is loaded, the TMPL looks fine, but no data appears for the <?php echo $this->mlsnum; ?> reference call.

Does each assignRef() need it's own function?

  • 写回答

3条回答 默认 最新

  • doupuchen6378 2012-11-28 16:10
    关注

    Try to change

    print_r($row[$column]);
    

    to this:

    return $row[$column];
    

    And this one

    parent::display($tpl);
    

    to

    return parent::display($tpl);
    

    Otherwise it's just no-result.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi