db = cs4_open(); $terms = $p; $title_arr = array( 'new' => '新着晩ごはんはコチラ!', 'pop' => '今日の人気晩ごはんはコチラ!', ); //var_dump($terms); //ページ番号セット $terms['page'] = (empty($terms['page'])) ? "1" : $terms['page'] ; //---- 該当条件レシピ一覧を取得 //DB接続 $db = DB::connect(constant('KTY_DSN')); if(DB::isError($db)){ echo "DB接続エラー:".DB::errorMessage($db)."\n"; exit; } if($p['con_id'] == "new"){ //******************************// // 新着晩ごはん取得 // //******************************// //$where = " pub_date like '$date%' and pub_flg = 0 and dlt_flg = 0"; $where = " pub_flg = 0 and dlt_flg = 0"; //5件までの場合 //$order = " pub_date desc limit 0,5"; //全データ $order = " pub_date desc"; $sql = "SELECT uniq_id, post_title, post_no, post_img, user_nm"; $sql.= sprintf(" FROM contents_data_tonari_contribute Where %s order by %s",$where,$order); $ret = $db->query($sql); if(DB::isError($ret)){ echo "

クエリの送信が失敗しました。

"; exit; } //件数取得 $count = $ret->numRows(); //顧客DB接続 $this->db = u4user_open(); while($row = $ret->fetchRow(DB_FETCHMODE_ASSOC)){ $array[post_no][] = $row['post_no']; $array[uniq_id][] = $row['uniq_id']; $array[title][] = $row['post_title']; $array[img][] = $row['post_img']; $array[user_nm][] = $row['user_nm']; } }else if($p['con_id'] == "pop"){ //******************************// // 人気晩ごはん取得 // //******************************// //$where = sprintf(" v.post_id = c.uniq_id and c.pub_date like '%s' ","$date%"); $where = " v.post_id = c.uniq_id"; $order = " v.poll desc limit 0,10"; $from = " contents_data_tonari_vote v ,contents_data_tonari_contribute c"; $sql = "select v.post_id,v.poll,c.post_date, c.post_no, c.post_title, c.uniq_id, c.post_img, c.user_nm "; $sql .= sprintf(" from %s where %s order by %s",$from,$where,$order); $res = $db->query($sql); if(DB::isError($res)){ echo "

クエリの送信が失敗しました。

"; exit; } //件数取得 $count = $res->numRows(); if(!empty($count)){ while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)){ $array[post_no][] = $row['post_no']; $array[uniq_id][] = $row['uniq_id']; $array[title][] = $row['post_title']; $array[img][] = $row['post_img']; $array[user_nm][] = $row['user_nm']; } } } //顧客DBの解放 u4user_close($this->db); //DB開放 $db->disconnect(); //デバッグ処理 if(constant('BBS_DEBUG_MODE')){ print "
-------------------
bh_recipe_search.php L178 Count -> "; var_dump($count); } // テンプレート読み込み $template =& loadTemplate( $p ); //- ページタイトルセット if($p['con_id'] == 'new'){ $page_title = "新着晩ごはん"; }else if($p['con_id'] == 'pop'){ $page_title = "人気の晩ごはん
投票数の多い順に上位10個を発表"; } $template->setVariable('page_title',$page_title); $template->setVariable('title',$page_title); //- 検索エラーハンドリング if($count){ $template->setCurrentBlock('__SerachResult__'); $template->setVariable('count',$count); $template->parseCurrentBlock(); $template->hideBlock('__SearchError__'); }else{ $template->TouchBlock('__SearchError__'); $template->hideBlock('__SearchResult__'); } //-- レシピ一覧作成 $start = ($terms['page'] - 1) * constant('TONARI_LIST_COUNT'); $limit = (($start + constant('TONARI_LIST_COUNT')) > $count) ? $count : $start + constant('TONARI_LIST_COUNT'); //var_dump($rcp_list); for($i = $start;$i < $limit;$i++){ //- ユーザ情報取得 //$user_detail = rcp_get_UserDetail($db,$array['post_no'][$i]); //画像パス取得 $img_path = sprintf("/home/www/public/image/tonari/%d_n-thm.jpg",$array['uniq_id'][$i]); //画像表示処理 if(!empty($array['img'][$i])){ $template->setVariable('img',sprintf("",str_replace(KTY_SERVER_ROOT,"",$img_path))); } //- Detail url作成 //2006.06.22 J,Nikaido Add $detail_url = sprintf("tonari_detail.php?p[uniq_id]=%d",$array['uniq_id'][$i]); //$detail_url = sprintf("%d",$array['uniq_id'][$i]); //- ユーザプロフィールリンクurl作成 //2006.06.22 J,Nikaido Add $user_prof_url = sprintf("userslist/%s",$array['post_no'][$i]); $template->setCurrentBlock('__RecipeList__'); if($p['con_id'] != "new"){ $template->setVariable('rank',($i + 1)."位"); } $template->setVariable('url',$detail_url); $template->setVariable('rcp_name',$array['title'][$i]); //$template->setVariable('user_name',"".$user_detail['mem_nick_nm']); $template->setVariable('user_name',"".$array['user_nm'][$i]); $template->parseCurrentBlock(); } //デバッグ処理 if(constant('BBS_DEBUG_MODE')){ print "
Page Now -> ".$terms['page']."
\n"; print "Total Count -> ".$count."
\n"; print "Show Limit -> ".$limit."
\n"; } $key_str = ""; if($terms['page'] > '1'){ $template->setCurrentBlock('__PagePrev__'); $template->setVariable('prev_page',($terms['page'] - 1)); $template->setVariable('con_id',$p['con_id']); $template->parseCurrentBlock(); }else{ $template->hideBlock('__PagePrev__'); } if($count > $limit){ $template->setCurrentBlock('__PageNext__'); $template->setVariable('next_page',($terms['page'] + 1)); $template->setVariable('con_id',$p['con_id']); $template->parseCurrentBlock(); }else{ $template->hideBlock('__PageNext__'); } $template->setVariable('contents_top',TONARI_NAME); $template->show(); //DB開放 cs4_close($this->db); } //var_dump($p); tonari_list( $p ); ?>