<戻る>'; $cnt_spl = 'SELECT COUNT(*) FROM qa_data WHERE cate = ' . $_GET['no']; $result = $db->query( $cnt_spl ); if( DB::isError($result) ) { print $result->getMessage(); } if(!$cnt = $result->fetchRow()){ header("Location:qa.php"); }else{ $num = $cnt[0]; } //ページリンク生成 if($num <= $limit){ $page_link = ''; }elseif($num > $limit && $page == 0){ $page_link = '次へ >'; }elseif(($num - $offset) < $limit){ $page_link = '< 前へ'; }else{ $page_link = '< 前へ   次へ >'; } $c_data = GetCateData($_GET['no']); $sql = 'SELECT * FROM qa_data WHERE cate = ' . $_GET['no'] . ' LIMIT ' . $limit . ' OFFSET ' . $offset; $result = $db->query( $sql ); if( DB::isError($result) ) { print $result->getMessage(); } $box = '
'; $box .= '
'; while( $row = $result->fetchRow() ) { $box .= '
' . mb_convert_encoding($row[1], 'SJIS', 'EUC-JP') . '
'; $box .= '
'; $row[2] = str_replace("\n", '
', $row[2]); // $row[2] = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","\\0", $row[2]); // $row[2] = ereg_replace("[[:alpha:]]+@[^<>[:space:]]+[[:alnum:]/]","\\0", $row[2]); $box .= mb_convert_encoding($row[2], 'SJIS', 'EUC-JP'); $box .= '
'; $box .= '
'; } $box .= '
'; }else{ $sql = 'SELECT * FROM qa_cate WHERE stat = 1'; $result = $db->query( $sql ); if( DB::isError($result) ) { print $result->getMessage(); } while( $row = $result->fetchRow() ) { $box .= '
'; } $page_link = ''; $return = ''; } $body = str_replace('%box%', $box, $body); $body = str_replace('%page_link%', $page_link, $body); $body = str_replace('%return%', $return, $body); $body = mb_convert_kana($body, 'k'); $body = ReplaceTable($body); $body = str_replace('%head_mes%', $head_mes, $body); preg_match_all("/<\*\*\*emoji_[a-zA-Z0-9]*\*\*\*>/", $body, $match); foreach( $match[0] as $val ) { //絵文字のキーを抜き出す preg_match("/[A-Z0-9]{4}?/", $val, $key); //絵文字を導き出す $emoji = Convert($key[0]); $body = str_replace($val, $emoji, $body); } echo str_replace('%doctype%', $mobile_data['doctype'], $header); echo $body; function GetCateData( $id ){ global $db; if( $id == '' || is_null( $id ) ){ return( false ); } $sql = 'SELECT * FROM qa_cate WHERE id = ?'; $sth = $db->prepare( $sql ); $result = $db->execute( $sth, array( $id ) ); if( DB::isError( $result ) ){ return( false ); } $row = $result->fetchRow(); foreach($row as $key => $value){ $row[$key] = mb_convert_encoding($value, "UTF-8", "EUC-JP"); } return( $row ); } ?>