Codeigniter

 

 

 

 

 

 

board.php

 

class Board extends CI_Controller {

	function __construct()
	{
		parent::__construct();
		//$this->load->database();
		$this->load->model('board_m');
		$this->load->helper(array('url', 'date'));
	}


	/*
		주소에서 메서드가 생략되었을 때 실행되는 기본 메서드
	 */
	public function index()
	{
		$this->lists();
	}


	/*
		사이트 헤더, 푸터가 자동으로 추가 된다.
	 */
	public function _remap($method)
	{
		//헤더 include
		$this->load->view('header_v');

		if(method_exists($this, $method))
		{
			$this->{"{$method}"}();
		}	

		//푸터 include
		$this->load->view('footer_v');
	}


/*
	 게시물 삭제

	 */
	function delete()
	{
		echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' ;

		//경고창 헬퍼 로딩
		$this->load->helper('alert');

		//게시물 번호에 해당하는 게시물 삭제
		$return=$this->board_m->delete_content('ci_board',$this->uri->segment(4));

		$pages=$this->_pageNumber();
		//게시물 목록으로 돌아가기
		if($return)
		{
			//삭제가 성공한 경우
			alert('삭제 되었습니다.', '/todo/board/lists/ci_board/page/'.$pages);
			exit;	
		}	
		else
		{
			//삭제가 실패한 경우
			alert('삭제 실패하였습니다.', '/todo/board/lists/ci_board/page/'.$pages);
			exit;	

		}
	}

 

 

board_m.php


	//게시물 삭제
	function delete_content($table, $no)
	{
		$delete_array=array(
			'board_id' =>$no
		);
		$result =$this->db->delete($table, $delete_array);
		//결과 반환
		return $result;
	}

 

view_v.php

		<table cellspacing="0" cellpadding="0" class="table table-striped">
			<thead>
				<tr>
					<th scope="col"><?php echo $views->subject;?></th>
					<th scope="col">이름 : <?php echo $views->user_name;?></th>
					<th scope="col">조회수 : <?php echo $views->hits;?></th>
					<th scope="col">등록일 : <?php echo $views->reg_date;?></th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<th colspan="4">
						<?php echo $views->contents;?>
					</th>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<th colspan="4"><a href="/bbs/board/lists/<?php echo $this->uri->segment(3);?>/page/<?php echo $this->uri->segment(7);?>" class="btn btn-primary">목록</a> 
					<a href="/todo/board/modify/board_id/<?php echo $this->uri->segment(3);?>/<?php echo $this->uri->segment(4);?>/page/<?php echo $this->uri->segment(6);?>" class="btn btn-warning">수정</a> 

<a href="/todo/board/delete/board_id/<?php echo $this->uri->segment(3);?>/<?php echo $this->uri->segment(4);?>/page/<?php echo $this->uri->segment(6);?>" class="btn btn-danger">삭제</a> 

				 <a href="/todo/board/write/<?php echo $this->uri->segment(3);?>/page/<?php echo $this->uri->segment(7);?>" class="btn btn-success">쓰기</a></th>
				</tr>
			</tfoot>
		</table>

 

 

 

 

 

 

 

about author

PHRASE

Level 60  머나먼나라

집을 다스리는 데에는 집을 다스리는 방법이 있고, 동리를 다스리는 데에는 동리를 다스리는 길이 있다. 또 나라나 천하를 다스리는 데에는 나라와 천하를 다스리는 수단이 있는 것이다. 제각기 그 방법을 달리해야 하는 것이다. -관자

댓글 ( 4)

댓글 남기기

작성