gpt4 book ai didi

php - 消息 : Undefined Variable userid , 工作区 ID

转载 作者:行者123 更新时间:2023-11-30 00:52:58 24 4
gpt4 key购买 nike

我正在开发一个 View ,该 View 使用文本框中的联接向我显示数据库中的数据。

现在我收到错误:

Message: Undefined variable: userid
Message: Undefined variable: workspaceid

以下是我的模型、 View 和 Controller

型号:-

function getMilestone($taskid, $userid,$workspaceid, $is_master_admin) {
$this->load->database();
if($is_master_admin) {
$this->db->select('user.title as usertitle, workspace.title as workspacetitle,workspace.id as workspaceid,task.title as tasktitle,task.id as taskid, milestone.*');//task.title as tasktitle,task.id as taskid,
} else {
$this->db->select('*');
}
$this->db->from(MILESTONE);
if($is_master_admin) {
$this->db->join(USER, 'milestone.userid = user.id', 'inner');

$this->db->join(WORKSPACE, 'workspace.id = milestone.workspaceid','inner');
$this->db->join(TASK, 'task.id = milestone.taskid', 'inner');
} else {

}
$this->db->where('taskid', $taskid);
if($is_master_admin) {
$this->db->order_by("userid", "asc");
} else {
$this->db->where('userid', $userid);
}
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
} else {
return false;
}
}

Controller :-

function addNew($taskid) {
if ($this->session->userdata('logged_in')) {
$session_data = $this->session->userdata('logged_in');
$id = $session_data['id'];
$username = $session_data['username'];
$is_master_admin = $session_data['master'];
$imagethumb = $session_data['imagethumb'];
$pendingbug = $this->bugmodel->getBug($id,$is_master_admin);
$pendingtask = $this->taskmodel->getTask($id,$is_master_admin);
$status_result = $this->getstatus->getEnumValues(MILESTONE,'status');
$result = $this->milestonemodel->getMilestone($taskid, $userid, $workspaceid, $is_master_admin) ;
$data='';
$data = array('username' => $username,
'is_master_admin' => $is_master_admin,
'imagethumb' => $imagethumb,
'result' => $result,
'status_result' => $status_result,
'taskid' => $taskid,
'pendingtask' => $pendingtask,
'pendingbug' => $pendingbug
);

$this->load->view('milestone/add_milestone', $data);
} else {
//If no session, redirect to login page
redirect('login', 'refresh');
}
}

查看:-

<div class="control-group">
<label class="control-label">Title<span class="required">*</span></label>
<div class="controls">
<input type="text" name="title" data-required="1" class="span6 m-wrap" readonly="readonly"value="<?php echo $result[0]->taskid; ?>"/> <p><?php echo form_error('title'); ?></p>
<input type="hidden" id="tasktype" name="tasktype" data-required="1" class="span2 m-wrap" value="<?php //echo $task_type ?>"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Workspace</label>
<div class="controls">
<input type="text" readonly="readonly" value="<?php echo $result[0]->workspacetitle; ?>"></input>
</div>

</div>

在我的 View 中,值是使用taskid打印; ?> & 工作区标题; ?> 在文本框中,但错误打印在页面顶部

最佳答案

试试这个 Controller ,

function addNew($taskid) {
if ($this->session->userdata('logged_in')) {
$session_data = $this->session->userdata('logged_in');
$id = $session_data['id'];
$username = $session_data['username'];
$is_master_admin = $session_data['master'];
$imagethumb = $session_data['imagethumb'];
$pendingbug = $this->bugmodel->getBug($id, $is_master_admin);
$pendingtask = $this->taskmodel->getTask($id, $is_master_admin);
$status_result = $this->getstatus->getEnumValues(MILESTONE, 'status');
$result = $this->milestonemodel->getMilestone($taskid, $username, $id, $is_master_admin);
$data = '';
$data = array('username' => $username,
'is_master_admin' => $is_master_admin,
'imagethumb' => $imagethumb,
'result' => $result,
'status_result' => $status_result,
'taskid' => $taskid,
'pendingtask' => $pendingtask,
'pendingbug' => $pendingbug
);

$this->load->view('milestone/add_milestone', $data);
} else {
//If no session, redirect to login page
redirect('login', 'refresh');
}
}

我认为$userid$workspace$username$id

关于php - 消息 : Undefined Variable userid , 工作区 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20813214/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com