일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- Flutter 설치
- flutter 앱 만들기
- 크기 리사이즈
- php
- StoreKit
- Review
- 정규식 문자치환
- flutter 설치하기
- android function
- flutter 총정리
- Swift
- db connect
- php 문자치환
- php ftp upload
- ftp download
- 문자치환
- flutter 환경설정
- SKStoreReviewController
- page navigation
- flutter 실행하기
- php 게시판
- php ftp download
- flutter getting started
- ftp연동
- regexp
- ftp upload
- flutter 완벽 가이드
- 검색구현
- 플러터
- AppStore
- Today
- Total
AppleTree iOS
php 게시판 전체 소스 (page navi, db connect, search) 본문
# db_conn.php
<?
$dbcon = mysql_connect('mysql_host_address','username','passwd') or die('연결오류');
$db = mysql_select_db('DB이름');
mysql_query('set names euckr'); //한글처리-euckr, utf-8로 할 경우 바꿔줌
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, must-revalidate");
?>
# page_navi.php
<?
$start_page = floor(($page-1)/$page_link_num)*$page_link_num+1;
$end_page = $start_page+$page_link_num-1;
if($end_page>$total_page) $end_page = $total_page;
$page_prev = $start_page-1;
$page_next = $end_page+1;
$navi_str = "";
if($start_page > 1)
{
$navi_str .= "<a href='".$page_name."page=1";
if($s_word) $navi_str .= "&s_kind={$s_kind}&s_word={$s_word}";
$navi_str .= "'><<</a> ";
$navi_str .= "<a href='".$page_name."page={$page_prev}";
if($s_word) $navi_str .= "&s_kind={$s_kind}&s_word={$s_word}";
$navi_str .= "'><</a> ";
}
for($i = $start_page ; $i <= $end_page ; $i++)
{
if($i== $page)
$navi_str .= "<b>{$i}</b> ";
else
{
$navi_str .= "<a href='".$page_name."page={$i}";
if($s_word) $navi_str .= "&s_kind={$s_kind}&s_word={$s_word}";
$navi_str .= "'>[{$i}]</a> ";
}
}
if($end_page < $total_page)
{
$navi_str .= " <a href='".$page_name."page={$page_next}";
if($s_word) $navi_str .= "&s_kind={$s_kind}&s_word={$s_word}";
$navi_str .= "'>></a>";
$navi_str .= " <a href='".$page_name."page={$total_page}";
if($s_word) $navi_str .= "&s_kind={$s_kind}&s_word={$s_word}";
$navi_str .= "'>>></a>";
};
?>
# index.php
<? include "include/db_conn.php" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=euc-kr">
<META http-equiv="X-UA-Compatible" content="IE=Edge"/>
<?
$page_name = 'index.php?';
$s_kind = $_REQUEST['s_kind'];
$s_word = $_REQUEST['s_word'];
$page = $_GET['page'];
if( !$page ) $page = 1;
if($s_word)
{
switch($s_kind)
{
case 'subject':
$sql = "select count(*) as cnt from `eventlist` where `eventname` like '%{$s_word}%'";
break;
}
}
else
{
$sql = "select count(*) as cnt from `eventlist`";
}
$res = mysql_query($sql);
$row = mysql_fetch_array($res);
$total = $row['cnt'];
$page_link_num = 10;
$rows_per_page = 10;
$total_page = ceil($total/$rows_per_page);
$start = ($page-1)*$rows_per_page;
if($s_word)
{
switch($s_kind)
{
case 'subject':
$sql = "select * from `eventlist` where `eventname` like '%{$s_word}%' limit {$start},{$rows_per_page}";
break;
}
}
else
{
$sql = "select * from `eventlist` order by num desc limit {$start},{$rows_per_page}";
}
$res = mysql_query($sql);
$num = mysql_num_rows($res);
$startnum = $start+1;
include('page_navi.php');
?>
<HTML>
<HEAD>
<title>REDIS 스크리밍 DB 관리</title>
</HEAD>
<body>
<form name='myform' method='post'>
<table width="1024" border="1" cellspacing="0" cellpadding="0" align="center">
<tr>
<th>제목1</th>
<th>제목2</th>
<th>제목3</th>
</tr>
<? if($num==0){?>
<tr>
<td colspan='7'><div align='center'>입력된 내용이 없습니다.</div></td>
</tr>
<? } else { ?>
<? for($i = 0;$i<$num;$i++ ) {
$rs = mysql_fetch_array($res);
?>
<tr>
<td ><?= $rs['column1']?></td>
<td><?= $rs['column2']?></td>
<td><?= $rs['column3'];?></td>
</tr>
<? }} ?>
<tr>
<td colspan='3'><div align='center'><?=$navi_str?></div></td>
</tr>
</table><p>
<div align="center">
<select name="s_kind">
<option value="subject" selected>행사명</option>
<option value="code">코드</option>
</select>
<input type="text" name="s_word" size="50" id="s_word">
<input type="submit" value="검색하기">
</div>
</form>
</body>
</html>
2013-07-12 : 검색후 실행할 수 없는 요청이하는 에러가 뜸.
(해결) 변수명 search_cmd → s_kind, search_word → s_word로 변경.
(설명) php가 글로벌 변수로 들어가기 때문에 변수명이 겹치면 에러가 뜨는 경우가 있는 모양이다.