| 제목 | todo 게시판 url문제 | ||
|---|---|---|---|
| 글쓴이 | 닉네임work | 작성시각 | 2021/10/21 19:52:40 | 
| 
                         | 
                |||
| 
                         main.php <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); /* * todo 컨트롤러 */ 
 class Main extends CI_Controller { function __construct() { parent::__construct(); $this->load->database(); $this->load->model('todo_m'); $this->load->helper(array('url', 'date')); } 
 public function index() { $this->lists(); } 
 /* * todo 목록 */ public function lists() { $data['list'] = $this->todo_m->get_list(); 
 $this->load->view('todo/list_v', $data); } /* * todo 조회 */ function view() { // todo 번호에 해당하는 데이터 가져오기 $id = $this->uri->segment(3); 
 $data['views'] = $this->todo_m->get_view($id); 
 // view 호출 $this->load->view('todo/view_v', $data); } } 
 /* End of file main.php */ /* Location: ./application/controllers/main.php */ 
 ------------------------------------------- todo_m.php <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 
 /* * todo 모델 * */ 
 class Todo_m extends CI_Model { function __construct() { parent::__construct(); } 
 function get_list() { $sql = "SELECT * FROM items"; 
 $query = $this->db->query($sql); 
 $result = $query->result(); 
 return $result; } /* * todo 조회 */ function get_view($id) { $sql = "SELECT * FROM items WHERE id='" . $id . "'"; 
 $query = $this -> db -> query($sql); 
 $result = $query -> row(); 
 return $result; } } 
 /* End of file todo_m.php */ /* Location: ./application/Models/todo_m.php */ 
 -------------------------------- view_v.php <!DOCTYPE html> <html> <head> <meta charset="UTF-8"/> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/> <title>CodeIgniter</title> <!--[if lt IE 9]> <script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <link type="text/css" rel='stylesheet' href="/todo/include/css/bootstrap.css" /> </head> <body> <div id="main"> <header id="header" data-role="header" data-position="fixed"> <blockquote> <p> 만들면서 배우는 CodeIgniter </p> <small>실행 예제</small> </blockquote> </header> 
 <nav id="gnb"> <ul> <li> <a rel="external" href="/todo/index.php/main/lists/">todo 애플리케이션 프로그램</a> </li> </ul> </nav> <article id="board_area"> <header> <h1>Todo 조회</h1> </header> <table cellspacing="0" cellpadding="0" class="table table-striped"> <thead> <tr> <th scope="col"><?php echo $views -> id;?> 번 할일</th> <th scope="col"><?php echo $views -> created_on;?></th> <th scope="col"><?php echo $views -> due_date;?></th> </tr> </thead> <tbody> <tr> <th colspan="3"> <?php echo $views -> content;?> </th> </tr> </tbody> <tfoot> <tr> <th colspan="4"> <a href="/todo/index.php/main/lists/" class="btn btn-primary">목록</a> <a href="/todo/index.php/main/delete/<?php echo $this -> uri -> segment(3); ?>" class="btn btn-danger">삭제</a> <a href="/todo/index.php/main/write/" class="btn btn-success">쓰기</a> </th> </tr> </tfoot> </table> </article> 
 <footer> <blockquote> <p><a class="azubu" href="http://www.cikorea.net/" target="blank">CodeIgniter 한국 사용자 포럼</a></p> <small>Copyright by <em class="black"><a href="mailto:zhfldi4@gmail.com">Palpit</a></em></small> </blockquote> </footer> </div> </body> </html> 
 --------------------------------- routes.php $route['default_controller'] = 'main'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; 
 ------------- 
 환경은 엔진엑스입니다. 현재 mnmp 통합 환경설정툴을 쓰고 있는데 
 http://localhost/todo/ 이걸로 리스트 목록이 나오는데 상세보기 부분이 안나옵니다. url이 어디인가요 ㅠㅠ 도와주세요 ㅠㅠㅠ 
 http://localhost/todo/index.php/main/view/1 어디 부분을 빼야할까요? 
 
 
  | 
                |||
| 이전글 | 코드이그나이터 라이브러리들 문의 (1) | ||
| 
                             
                                변종원(웅파)
                                /
                                2021/10/22 08:10:19 /
                                추천
                                0
                             
                             | 
                    
| 
                             
                                변종원(웅파)
                                /
                                2021/10/22 08:11:41 /
                                추천
                                0
                             
                            
                                http://localhost/todo/index.php/main/lists 로 접속했을 때 리스트가 나오는지도 확인해보세요
                             
                         | 
                    
| 
                             
                                닉네임work
                                /
                                2021/10/22 08:46:50 /
                                추천
                                0
                             
                            http://localhost/todo/index.php/main/lists 이대로는 안나오고 기본 컨트롤러를 main으로 지정후 http://localhost/todo/index.php 이렇게만 리스트 페이지가 나옵니다 ㅠㅠ 다음으로 상세페이지는 윗 url주소가 안나옵니다.. 404만 뜨고 있습니다.. 버전은 ci3을 쓰고 있습니다~! 
  | 
                    
책대로 했다면 http://localhost/todo/index.php/main/view/1 이 주소가 맞습니다.
그리고 에러메세지는 명확하게 전달해야 합니다.
안나오는게 어떤 상황인가요? 아무것도 안보이는 화면인건지? 404인건지?
짊문하실 때는 화면에 나온 에러메세지와 소스코드를 올리시면 빠른 답을 받을 수 있습니다.
책은 ci2점대를 기준으로 썼습니다. 그래서 이후 버전과 파일명, 메소드명 명명규측이 다릅니다.
컨트롤러 파일명 대소문자, 메소드 대소문자 확인해보시기 바랍니다.