컨트롤러를 기록 검색합니다는 CodeIgniter를 통해 사용자 이벤트에
public function searchevent() {
$this->load->model("users_model");
$data["rows"] = $this->users_model->search_member_events();
$this->load->view("search_view", $data);
}
모델 :
public function search_member_events() {
$this->db->select('*');
$this->db->from('users');
$this->db->where('id', '$userid');
$this->db->join('events', 'users.id = events.user_id');
$q = $this->db->get();
if ($q->num_rows() > 0) {
foreach ($q->result() as $row) {
$data[] = $row;
}
return $data;
}
}
보기 :
<div class="member_search_results">
<h2>Your Events </h2>
<?php if(isset($rows)) : foreach($rows as $r): ?>
<div class="outer">
<div class='single_result'>
<strong class='title'><?php echo $r->title ?></strong>
<div class="outer">
<span class='start'><strong>Starts at:</strong> <?php echo $r->start ?></span>
<span class='end'><strong>Ends at:</strong> <?php echo $r->end ?></span>
<span class='time'><strong>Time:</strong><?php echo $r->time ?></span>
</div>
<div class="outer">
<span class='location'><strong>Location:</strong><?php echo $r->location ?></span>
</div>
<div class="outer">
<span class='description'><strong>Details:</strong><?php echo $r->description ?></span>
</div>
</div>
<?php endforeach; ?>
<?php else : ?>
<h2>You do no have any events yet, please <?php echo anchor ("createevent", "Create Event") ?></h2>
<?php endif; ?>
</div>
나는 두 개의 데이터베이스 테이블에 사용자와 이벤트가 있습니다. 내가 원하는 것은 사용자가 로그인했을 때입니다. EVENT 테이블에서 로그인 한 모든 이벤트가 사용자 대시 보드에 표시되어야합니다. 지금은 모든 이벤트를 표시하고 있습니다.
문제를 조금 더 명확하게 할 수 있습니까? –
사용자가 로그인 할 때 데이터베이스의 이벤트가 대시 보드에 표시되어 편집하거나 삭제할 수 있습니다. 지금 내 쿼리는 데이터베이스에서 모든 이벤트를 표시합니다.이 특정 사용자의 –
모델에서 사용자 ID를 전달하고 해당 사용자 ID의 이벤트를 선택할 수 있습니다. –