만들면서 배우는 CodeIgniter Q&A

제목 페이지 56 질문좀 드릴게요.
글쓴이 attributes 작성시각 2013/11/09 17:03:41
댓글 : 3 추천 : 0 스크랩 : 0 조회수 : 10082   RSS
main.php       경로   www/todo/application/controllers/                      
todo_m.php          경로     www/todo/application/models/
list_v.php        경로     www/todo/application/views/todo/
db 설정후 
위 세개의모두 책 내용 대로 위치 시키고
http://localhost/todo/index.php/main/lists/
로 접속하면 리스트가 떠야 정상아닌가요..?
아무런 메시지도 뜨지않고...

어디서 잘못된건지 모르겠네요...

도와 주세요 ㅠ.ㅠ 

----------------------------main.php
<?php
if (!defined('BASEPATH')) exit ('No direct script access allowed');

class Main extends CI_Controller
{
 function __construct()
 {
  parent::__construct();
  $this->load->database();
  $this->load->model('todo_m');
  $this->load->helper('url');
  $this->load->helper('date');
 }
}

public function index()
{
 $this->lists();
}

public function lists()
{
 $data['list'] = $this->todo_m->get_list();
 $this->load->view('todo/list_v', $data);
}
}
 
----------------------------todo_m.php
<?php if (!idfined('BASEPATH')) exit('No direct script access allowed');

class Todo_m extends CI_Model
{
 function __construct()
 {
  parent::__construct();
 }
}

function get_list()
{
 $sql = "select * from items";
 $query = mysql_query($sql);
 $result = mysql_fetch_row($query);
 return $result;
}
}
 
---------------------------list_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>
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/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">번호</th>
      <th scope="col">내용</th>
      <th scope="col">시작일</th>
      <th scope="col">종료일</th>
     </tr>
    </thead>    
    <tbody>
<?php
foreach ($list as $lt)
{
?>
    <tr>
     <th scope="row">
      <?php echo $lt->id;?>
     </th>
     <td><a rel="external" href="/todo/index.php/main/view/<?php echo $lt->id;?>"> <?php echo $lt->content;?></a></td>
     <td><time datetime="<?php echo mdate("%Y-%M-%j", human_to_unix($lt->created_on));?>"><?php echo $lt->created_on;?></time></td>
     <td><time datetime="<?php echo mdate("%Y-%M-%j", human_to_unix($lt->due_date));?>"><?php echo $lt->due_date;?></time></td>
    </tr>
<?php
}
?>

</tbody>
<tfoot>
 <tr>
  <th colspan="4"><a href="/todo/index.php/main/write/" class="btn btn-success">쓰기</a></th>
 </tr>
 </tfoot>
</table>
<div><p></p></div>
</article>

<footer id="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:advisor@cikorea.net">웅파</a></small>
<blockquote>
</footer>

 </div>
</body>

</html>
아 정말 잘 배워보고 싶은데 어렵네요..

혹 문제가 된다면 자삭하겠습니다.
 


 
 다음글 p198 form_open 에 오탈자 하나 추가요. (1)
 이전글 세션관련 질문입니다. (4)

댓글

변종원(웅파) / 2013/11/09 23:46:57 / 추천 0
하얀 화면만 뜬다면 대부분 db관련 에러입니다.

모델에 책과 다른 게 보이네요.
ci에서는 mysql_query()를 사용하지 않습니다.

ci세상에 오셨으면 ci의 active record를 사용하세요.

승희아빠 / 2013/11/13 01:33:20 / 추천 0
 main.php 도 todo_m 도 클래스를 닫아 버리셨네요.

구조를 설명 드리면

class 클래스명
{
    function 함수명
    {
        함수내용들;
    } // 함수 닫기

    function 함수명
    {
        함수내용들;
    } // 함수 닫기

} // 클래스 닫기


이래야 하는데 님은

class 클래스명
{
    function 함수명
    {
        함수내용들;
    } // 함수 닫기
} // 클래스 닫기 -> 여기 밑으로는 쓰던가 말던가 ^^;

function 함수명
{
    나는 쓸모없는 일반 함수인가 보다...;
} // 함수 닫기

} // 이건 또 머지? 뭘 닫자는 건가요?


이런식으로 클래스를 쓰셨네요.  오류가 안 나는게 당연합니다.

attributes / 2013/11/20 18:25:49 / 추천 0
 정말 감사합니다.. 그런 기초적인걸 ㅜ.ㅜ ... 열공 하겠습니다! :)