query($sql); if(DB::isError($ret)){ echo "

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

"; exit; } $num = $ret->numRows(); if(!empty($num)){ //件数分だけループ while($int = $ret->fetchRow(DB_FETCHMODE_ASSOC)){ $no1 = $int['rcp_no1']; $no2 = $int['rcp_no2']; } } $where = sprintf("c.uniq_id = %s and c.dlt_flg = 0 ",$uniq_id); //オススメレシピが2つあるときの処理 if(!empty($no1) && !empty($no2)){ $join = " inner join contents_data_bsc_r_new as r1 on r1.rcp_no = c.rcp_no1 "; $join.= " inner join contents_data_bsc_r_new as r2 on r2.rcp_no = c.rcp_no2"; $sql = "select c.post_title, c.post_no, c.post_body, c.post_date, c.uniq_id, c.post_img, c.user_nm ,"; $sql.= " c.rcp_no1, r1.rcp_nm name1 , c.rcp_no2, r2.rcp_nm name2"; $sql.= sprintf(" from contents_data_tonari_contribute c %s where %s",$join,$where); } //オススメレシピが1番目しかないときの処理 if(!empty($no1) && empty($no2)){ $join = " inner join contents_data_bsc_r_new as r1 on r1.rcp_no = c.rcp_no1 "; $sql = "select c.post_title, c.post_no, c.post_body, c.post_date, c.uniq_id, c.post_img, c.user_nm ,"; $sql.= " c.rcp_no1, r1.rcp_nm name1 "; $sql.= sprintf(" from contents_data_tonari_contribute c %s where %s",$join,$where); } //オススメレシピが2番目しかないときの処理 if(empty($no1) && !empty($no2)){ $join = " inner join contents_data_bsc_r_new as r2 on r2.rcp_no = c.rcp_no2"; $sql = "select c.post_title, c.post_no, c.post_body, c.post_date, c.uniq_id, c.post_img, c.user_nm ,"; $sql.= " c.rcp_no2, r2.rcp_nm name2"; $sql.= sprintf(" from contents_data_tonari_contribute c %s where %s",$join,$where); } $ret = $db->query($sql); if(DB::isError($ret)){ echo "

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

"; exit; } //件数取得 $num = $ret->numRows(); while($row = $ret->fetchRow(DB_FETCHMODE_ASSOC)){ $no = $row['post_no']; $template->setCurrentBlock('__new_detail__'); //画像パス取得 $img_path = sprintf("/home/www/public/image/tonari/%d_n.jpg",$row['uniq_id']); //画像表示処理 if(!empty($row['post_img'])){ $template->setVariable('img',sprintf("",str_replace(KTY_SERVER_ROOT,"",$img_path))); } if(strlen($row['post_date']) > 10){ $date = substr($row['post_date'],0,10); //日付変換 $date = str_replace('-','/',$date); } $template->setVariable('title',$row['post_title']); $template->setVariable('cmt',$row['post_body']); $template->setVariable('date',$date); $template->setVariable('uniq_id',$uniq_id); $template->setVariable('user_name',$row['user_nm']); $template->setCurrentBlock('__rcp1__'); $template->setVariable('rcp_no1',$row['rcp_no1']); $template->setVariable('name1',$row['name1']); $template->parseCurrentBlock(); $template->setCurrentBlock('__rcp2__'); $template->setVariable('rcp_no2',$row['rcp_no2']); $template->setVariable('name2',$row['name2']); $template->parseCurrentBlock(); } //顧客情報からニックネーム取得 //$user_detail = rcp_get_UserDetail($db,$no); $template->setVariable('master_no',$no); $template->parseCurrentBlock(); //- コンテンツトップ戻りリンク $template->setVariable('contents_top_url','tonari_top.php'); $template->setVariable('contents_top',TONARI_NAME); //テンプレート表示 $template->show(); } tonari_detail( $p ); ?>