"; print "メイン:".$r_id1."
"; print "脇役:".$r_id2."
"; print "主食:".$r_id3."

"; print $id."
"; print $cook."
"; print $genre."

"; //******************************// // データ取得処理 // //******************************// //本日日付取得 $base_day = date("d"); $base_month = date("m"); $base_year = date("Y"); $terms = $p; //DB接続 $this->db = cs4_open(); //******************************// // DB取得処理 // //******************************// //メインwhere句定義 if($id == 1){ if(!empty($genre)){ $where1 = sprintf(" rcp_gnr = '10000000' and %s and rcp_dlt = 0 ", $and); }else{ $where1 = " rcp_gnr = '10000000' and rcp_style LIKE '%お弁当%' and rcp_dlt = 0 "; } }else{ if(!empty($r_id1)){ $where1 = " rcp_no = '$r_id1' and rcp_dlt = 0 "; }else{ $where1 = " rcp_gnr = '10000000' and rcp_style LIKE '%お弁当%' and rcp_dlt = 0 "; } } //脇役where句定義 if($id == 2){ $where2 = " rcp_gnr = '10000000' and (rcp_style LIKE '%カンタンおかず%' or rcp_style LIKE '%さっと作れる%') and rcp_dlt = 0 "; }else{ if(!empty($r_id2)){ $where2 = " rcp_no = '$r_id2' and rcp_dlt = 0 "; }else{ $where2 = " rcp_gnr = '10000000' and (rcp_style LIKE '%カンタンおかず%' or rcp_style LIKE '%さっと作れる%') and rcp_dlt = 0 "; } } //主食where句定義 if($id == 3){ $where3 = " rcp_gnr = '10000000' and rcp_kind LIKE '%主食%' and rcp_dlt = 0 "; }else{ if(!empty($r_id3)){ $where3 = " rcp_no = '$r_id3' and rcp_dlt = 0 "; }else{ $where3 = " rcp_gnr = '10000000' and rcp_kind LIKE '%主食%' and rcp_dlt = 0 "; } } // テンプレート読み込み $template =& loadTemplate( $p ); //メイン件数取得 $ct1 = cs4_num_rows($this->db,'bsc_r_new',$where1); //カウント用変数 $i = 0; if($ct1){ $ret=cs4_select($this->db,"bsc_r_new",$where1); //件数分だけループ while($row = cs4_fetch_row($ret)) { $array[main_no][$i] = $row['rcp_no']; $array[main_nm][$i] = $row['rcp_nm']; $i ++; } } //脇役件数取得 $ct2 = cs4_num_rows($this->db,'bsc_r_new',$where2); $i = 0; if($ct2){ $ret=cs4_select($this->db,"bsc_r_new",$where2); //件数分だけループ while($row = cs4_fetch_row($ret)) { $array[submain_no][$i] = $row['rcp_no']; $array[submain_nm][$i] = $row['rcp_nm']; $i ++; } } //主食件数取得 $ct3 = cs4_num_rows($this->db,'bsc_r_new',$where3); $i = 0; if($ct3){ $ret=cs4_select($this->db,"bsc_r_new",$where3); //件数分だけループ while($row = cs4_fetch_row($ret)) { $array[sub_no][$i] = $row['rcp_no']; $array[sub_nm][$i] = $row['rcp_nm']; $i ++; } } //******************************// // テンプレート引渡し処理 // //******************************// $nowdate_count = (mktime(0,0,0,date("m"),date("d"),date("Y")) - mktime(0,0,0,1,1,2006)) / (24*60*60); if(!empty($ct1)){ $index = $nowdate_count % $ct1; //画像パス取得 $main_path = sprintf("/home/www/public/image/recipe/%d_n-thm.jpg",$array[main_no][$index]); //print $main_path."

"; //メイン画像 if(file_exists($main_path)){ $template->touchBlock('__Main_Image__'); $template->setVariable('main_image',sprintf("",str_replace(KTY_SERVER_ROOT,"",$main_path))); }else{ $template->hideBlock('__Main_Image__'); } } if(!empty($ct2)){ $index = $nowdate_count % $ct2; //メインと同じときの処理 if($array[main_no][$index] == $array[submain_no][$index]){ $submain_path = sprintf("/home/www/public/image/recipe/%d_n-thm.jpg",$array[submain_no][$index + 1]); }else{ $submain_path = sprintf("/home/www/public/image/recipe/%d_n-thm.jpg",$array[submain_no][$index]); } //脇役画像 if(file_exists($submain_path)){ $template->touchBlock('__SubMain_Image__'); $template->setVariable('submain_image',sprintf("",str_replace(KTY_SERVER_ROOT,"",$submain_path))); }else{ $template->hideBlock('__SubMain_Image__'); } } if(!empty($ct3)){ $index = $nowdate_count % $ct3; //主食と同じときの処理 if($array[main_no][$index] == $array[sub_no][$index] || $array[submain_no][$index] == $array[sub_no][$index]){ $sub_path = sprintf("/home/www/public/image/recipe/%d_n-thm.jpg",$array[sub_no][$index + 2]); }else{ $sub_path = sprintf("/home/www/public/image/recipe/%d_n-thm.jpg",$array[sub_no][$index]); } //主食画像 if(file_exists($sub_path)){ $template->touchBlock('__Sub_Image__'); $template->setVariable('sub_image',sprintf("",str_replace(KTY_SERVER_ROOT,"",$sub_path))); }else{ $template->hideBlock('__Sub_Image__'); } } clearstatcache(); $template->touchBlock('__Main__'); //メイン表示 $template->setVariable('main_no',$array[main_no][$index]); $template->setVariable('main_nm',$array[main_nm][$index]); //脇役表示 //メインと同じときの処理 if($array[main_no][$index] == $array[submain_no][$index]){ $template->setVariable('submain_no',$array[submain_no][$index + 1]); $template->setVariable('submain_nm',$array[submain_nm][$index + 1]); }else{ $template->setVariable('submain_no',$array[submain_no][$index]); $template->setVariable('submain_nm',$array[submain_nm][$index]); } //主食表示 if(!empty($ct3)){ if($array[main_no][$index] == $array[sub_no][$index] || $array[submain_no][$index] == $array[sub_no][$index]){ $template->setVariable('sub_no',$array[sub_no][$index + 2]); $template->setVariable('sub_nm',$array[sub_nm][$index + 2]); }else{ $template->setVariable('sub_no',$array[sub_no][$index]); $template->setVariable('sub_nm',$array[sub_nm][$index]); } }else{ $template->setVariable('sub_no','bentou_search.php?id=3&r_id1={main_no}&r_id2={submain_no}'); $template->setVariable('sub_nm','該当レシピが見つかりません。'); } $template->parseCurrentBlock(); $template->show(); //DB開放 cs4_close($this->db); } bentou_top( $p ); ?>