English 中文(简体)
不确定指数:在PHP代码配对器中,同时发送变量
原标题:Undefined index: in PHP codeigniter while sending variable

我的控制者:

public function thread($page =  empty )
{

    $data[ user_id ] = $this->tank_auth->get_user_id();
    $data[ username ] = $this->tank_auth->get_username();
    //User data variable grab
    //default template load data
    $data[ thread ] = $this->thread_model->get_thread($page);
    $data[ title ] = ucfirst($page); // Capitalize the first letter
    $data[ replies ] = $this->thread_model->get_reply($data[ thread ][ thread_id ]);
    $this->thread_model->view_increment($data);
    $this->load->view( templates/head , $data);
    $this->load->view( main/wrapper-start , $data);
    $this->load->view( templates/leftbar , $data);
    $this->load->view( main/thread , $data);
    $this->load->view( main/wrapper-end , $data);
    $this->load->view( templates/footer , $data);

}

错误出现在<代码>数据[答复]线上:

严重程度:通知

Message:无定义的指数:read-id

文件名称:控制员/主人。

电话:40

我的示范守则提到:$this->thread_model->get_reply

public function get_reply($thread_id)
{

    $query = $this->db->query("SELECT r.reply_id FROM reply_thread rt
    INNER JOIN replies r
    ON rt.reply_id = r.reply_id
    WHERE thread_id = ". $thread_id);
    $replies = $query->result_array();
    $replyarray = array();
    foreach ($replies as $reply)
    {
        $id = $reply[ reply_id ];
        $query = $this->db->query("SELECT * FROM replies WHERE reply_id= $id ");
        $thisRow = $query->row_array();
        $replyarray[] = $thisRow;
    }

    return $replyarray;
}

为什么这一错误正在蔓延? 除错误外,该页的负荷完全是细微的。

我的“阅读”模式

public function get_thread($page)
{
    $slug = $page;
    $query = $this->db->get_where( thread , array( slug  => $slug));
    return $query->row_array();
}

使用<条码>(r)([现值]美元)

Array ( [thread_id] => 233 [owner_id] => 8 [subject] => Repercussions of D3 addiction [body] => 1. signs of unhygienic practices 2.become irritable when forced to stop playing 3. carpal tunnel 4. loss of interest in pursuing a significant other 5. sleep deprivation 6. malnutrition There s nothing positive about this. [timestamp] => 2012-05-08 19:03:02 [replystamp] => 2012-05-09 12:38:32 [last_post_id] => 3 [slug] => 233-repercussions-of-d3-addiction [replies_num] => 2 [views] => 21 )
问题回答

我认为你可以尝试:

$threadinfo = $this->thread_model->get_thread($page);
$data[ thread ] = $threadinfo;
$data[ replies ] = $this->thread_model->get_reply($threadinfo->thread_id);




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签