function table_make() { $getValue['page'] = isset($_GET['page']) ? $_GET['page'] : 1; $sql = "select * from ycj_first_board"; //myDB.php의 MYSQL_CN()메소드를 불러온다. $rscID = MYSQL_CN(); //위의 sql을 쿼리실행 $rsc = mysql_query($sql, $rscID); // if($pageall=mysql_num_rows($rsc)){ // // echo "쿼리성공"; // echo (mysql_error($rscID)); // } $pagelimit = 5; $total_page_num = mysql_num_rows($rsc); $page_num = ceil($total_page_num / $pagelimit); $start = ($getValue['page'] - 1) * 5; //페이지의 레코드를 배열로 $sql = "select * from ycj_first_board order by board_id desc limit {$start}, {$pagelimit}"; //전체 테이블 출력 sql실행 $rsc = mysql_query($sql, $rscID); while ($result = mysql_fetch_row($rsc)) { echo "<tr>"; echo "<td>{$result[0]}</td>"; //글번호 echo "<td><a href='view.php?board_id={$result[0]}'>{$result[3]}</td>"; //작성자 echo "<td>{$result[4]}</td>"; //제목 echo "<td>{$result[6]}</td>"; //조회수 echo "<td>{$result[7]}</td>"; //작성일 echo "</tr>"; } echo "<tr><td colspan='5'>"; $start_page = floor(($getValue['page'] - 1) / $pagelimit) * $pagelimit + 1; $end_page = $start_page + $pagelimit - 1; //테스트 if ($start_page > $pagelimit) { $before_num = $start_page - 1; echo "<a href=list.php?page={$before_num}>◀</a>"; } //테스트끝 for ($i = $start_page; $i <= $end_page; $i++) { if ($i <= $page_num) { echo "<a href=list.php?page={$i}>{$i}</a>"; } } if ($end_page < $page_num) { $after_num = $end_page + 1; echo "<a href=list.php?page={$after_num}>▶</a>"; } echo "</td></tr>"; mysql_close($rscID); }
<?php /** * Created by PhpStorm. * User: user * Date: 2015-10-08 * Time: 오후 8:02 */ include 'db_CN.php'; $connect_id = MYSQL_CN(); $board_id = isset($_POST['mode']) ? $_POST['mode'] : false; $sql = "select * from ycj_first_board where board_id='{$board_id}'"; $rsc = mysql_fetch_row(mysql_query($sql, $connect_id)); ?> <html> <head> </head> <body> <table border="1"> <form action="list.php" method="post"> <tr> <td>아이디</td> <td><input type="text" name="user_id" value="<?php echo "{$rsc['2']}"; ?> "</td> </tr> <tr> <td>닉네임</td>
<?php include 'db_CN.php'; $rscID = MYSQL_CN(); $board_id = isset($_GET['board_id']) ? $_GET['board_id'] : "false"; $sql = "select * from ycj_first_board where board_id={$board_id}"; $rsc = mysql_fetch_row(mysql_query($sql, $rscID)); ?> <html> <head> </head> <body> <table border='1'> <tr> <td>아이디:</td> <td><?php echo "{$rsc['2']}"; ?> </td> <td>이름:</td> <td><?php echo "{$rsc['3']}"; ?> </td> </tr> <tr> <td>제목</td> <td colspan='3'><?php echo "{$rsc['4']}"; ?> </td>