-
[PHP] php 이전 글, 다음 글Engineering WIKI/PHP 2020. 4. 26. 10:01
function sql_query ($sql) { $result = mysql_query($sql); $row = mysql_fetch_assoc($result); if(mysql_errno() > 0) echo "원문: ".$sql."<br/>"; return $row; } <? $get_no = $_GET['no']; $pre = sql_query("select no, subject from blog where no = (select max(no) from blog where no < $get_no)"); $odd = sql_query("select no, subject from blog where no = (select min(no) from blog where no > $get_no)"); if($pre){ ?> <p><input type="button" value="< 윗글" class="btn1_2" onclick="location.href='./view3.php?no=<?echo $pre[no];?>';"/></p> <? } if($odd){ ?> <p class="r"><input type="button" value="아랫글 >" class="btn1_2" onclick="location.href='./view3.php?no=<?echo $odd[no];?>';"/></p> <? } ?>
그리고 $pre와 $odd가 있을 때만 출력하게하여 없는 테이블은 조회 하지 못하도록 하였다.
'Engineering WIKI > PHP' 카테고리의 다른 글
[PHP] 배열 중복 제거 (0) 2020.03.09 [PHP] PHP & Jquery (select box form submit after selected) (0) 2020.02.16 [PHP] 자신에게 폼 제출 (0) 2019.08.17 [PHP] foreach 예제 (0) 2019.08.12 [PHP] PHP 배열 → JS (0) 2018.09.01