= "4.1.0"){ extract($_GET); extract($_POST); extract($_COOKIE); extract($_SERVER); } //1ページ当りの表示件数を設定します $PAGESIZE = 20; //keyパラメータ処理 if(isset($key) && $key != ''){ $key = mb_convert_encoding($key, "UTF-8", "EUC-JP"); $key = str_replace("〜","〜", $key);//波ダッシュを全角チルダに変換 $key = str_replace(" "," ", $key); $key = trim($key); if(ereg(" or ",$key)){ $keys = explode(" or ", $key); $connection = " OR "; }else{ $keys = explode(" ", $key); $connection = " AND "; } for($i = 0; $i < sizeof($keys); $i++) { if (strlen($keys[$i]) > 0) { $where_q[] = "question LIKE '%$keys[$i]%'"; $where_a[] = "answer LIKE '%$keys[$i]%'"; } } $where_q_str = implode($connection,$where_q); $where_a_str = implode($connection,$where_a); $where = " WHERE ($where_q_str) OR ($where_a_str)"; $key = urlencode($key); $param_key = "&key=$key"; } //ページ情報初期化 if (!isset($page))$page = 1; //DB接続 $con = pg_connect($connect_string); $setencode = "SET CLIENT_ENCODING TO 'UNICODE'"; pg_exec($con,$setencode); //登録件数取得 $cntsql = "select count(*) as cnt from onayami".$where; $rst = pg_query($con , $cntsql); $col = pg_fetch_array($rst); $totalcount = $col["cnt"]; //総ページ数表示 $totalpage = ceil($totalcount / $PAGESIZE); $startnum = ($PAGESIZE * ($page - 1) + 1); $endnum = ($PAGESIZE * $page) > $totalcount?$totalcount:($PAGESIZE * $page); $pagehead = "
【$totalcount 件中 ".$startnum." - ".$endnum."件目を表示中】
"; //ページネーション ナビゲーション if ($page > 1) { $pagenavi .= "<" ."前の $PAGESIZE 件   "; } if ($totalpage > 1 and $page < $totalpage) { $pagenavi .= "" ."次の $PAGESIZE 件>"; } //データ取得 $sql = "select * from onayami" . $where . " order by count DESC offset " . $PAGESIZE * ($page - 1) . "limit $PAGESIZE"; $rst = pg_query($con , $sql); $body .= "\n"; //DB切断 pg_free_result($rst); $con = pg_close($con); $key = urldecode($key); ?>
お悩み相談Q&A
ホーム > お悩み相談Q&A