/* ********************************************************************************* * システム:katsuyo.net * *===============================================================================* * クラス:diet_rank |モジュール:diet_rank.php * * 概要 :ランキングレシピ ダイエットランキング画面 * * パス :APP_HOME/diet/ * * 作成 :2006/08/10 J.Nikaido * *-------------------------------------------------------------------------------* * 更新 : * ********************************************************************************* */ require_once('../prepare.php'); require_once('lib/diet_function.php'); //- メンバーチェック if("e" == $p['carrier']){ chdir(dirname(__FILE__) . "/authcheck"); require_once("../authcheck/authcheck.php"); chdir(dirname(__FILE__)); } $db = u4user_open(); if(!get_UserDetail_uid($db, $p['uid'], '0', '1') && MEMBER_CHECK){ header("Location: " . MEMBER_REGIST_URL . "?p[contents]=" . substr(strrchr(dirname( __FILE__ ) , '/'), 1)); exit; } function diet_rank( $p ){ //DB接続 $db = DB::connect(constant('KTY_DSN')); if(DB::isError($db)){ echo "DB接続エラー:".DB::errorMessage($db)."\n"; exit; } $where = " d.dlt_flg = 0 and d.uniq_id = u.set_id"; $group = " u.set_id "; $from = " contents_data_kty_diet_set_users u, contents_data_kty_diet_set d"; $order = " num desc "; $sql = " select u.set_id, count( u.set_id ) as num, d.set_name,d.date "; $sql .= sprintf(" from %s where %s group by %s order by %s limit 0,10",$from,$where,$group,$order); $res = $db->query($sql); if(DB::isError($res)){ echo "
クエリの送信が失敗しました。
"; exit; } //件数取得 $num = $res->numRows(); // テンプレート読み込み $template =& loadTemplate( $p ); $i = 0; while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)){ //文字列置換 if('' != $row['date']){ $ymd = str_replace('-','.',substr($row['date'],0,10)); } $template->setCurrentBlock('__List__'); $template->setVariable('rank',$i + 1); $template->setVariable('set_id',$row['set_id']); $template->setVariable('set_name',$row['set_name']); $template->setVariable('date',$ymd); $template->parseCurrentBlock(); $i++; } if(empty($num)){ $template->hideBlock('__List__'); } $template->show(); } diet_rank( $p ); ?>