$_GET["c"])); $title = $rowt["category"]; //並び順の指定 if ($title=="新着アイテム") { $order = "registerday desc"; } else { $order = "s_code"; } $panlist = pankuzu($rowt); $sub_cate = search_subcate($rowt["hierarchy"]); //商品SQL $sql = "select * from s_category_tb,shouhin_tb ". "where sc_id='".$rowt["s_id"]."' and ss_id=s_id ". "and public = 'on' order by ".$order; } $stmt = query_sql($sql); $total=$stmt->rowCount(); //ページ機能 $page = LIST_MAX; $p = ($_GET["p"]=="") ? 1 : $_GET["p"]; $st = ($p-1) * $page; $page_list = page_info($page,$total,$p); $sql.=" limit ".$st.",".$page; $stmt = query_sql($sql); $p_num = $stmt->rowCount(); $com_top = html_entity_decode($rowt["com_top"]); $com_bottom = html_entity_decode($rowt["com_bottom"]); $top = URL; $str.=<<トップ > {$panlist}

{$title}

{$com_top}


{$sub_cate}

{$total}件中{$p_num}件表示

{$page_list}
HTML; //商品一覧 if ($total<=0) { $str.=$title."には商品がありません"; $str.=<< HTML; return $str; } $i=1; while($row=db_to_html($stmt->fetch(PDO::FETCH_ASSOC))) { $str.= ($i%3==1) ? "
" : ""; //Newマークをつけるか $new = search_new($row["registerday"]); //価格 $price = info_price($row); $str.=<<


{$new} {$row["s_name"]}

{$price}

HTML; $str.= ($i%3==0) ? "
" : ""; $i++; } $str.=($i%3!=1) ? "" : ""; $str.=<<
{$page_list}

{$com_bottom} HTML; return $str; } /*------------------------------------------------------------ 3段階までのサブカテゴリー ------------------------------------------------------------*/ function search_subcate($hierarchy) { //下階層をみにいく 3段階まで $sql = "select * from category_tb where hierarchy='".($hierarchy+1)."'". " and o_id='".$_GET["c"]."'"; $stmt = query_sql($sql); if ($stmt->rowCount()>0) { $sub_cate="このカテゴリーには以下のカテゴリーが含まれています

"; while($row=db_to_html($stmt->fetch(PDO::FETCH_ASSOC))) { $str.=<< {$row["category"]} HTML; $sql2 = "select * from category_tb where hierarchy='".($row["hierarchy"]+1)."'". " and o_id='".$row["s_id"]."'"; $stmt2 = query_sql($sql2); if ($stmt2->rowCount()>0) { while($row2=db_to_html($stmt2->fetch(PDO::FETCH_ASSOC))) { $str.=<< ◆{$row2["category"]}
HTML; } $str.="
"; } } } return $str; } /*------------------------------------------------------------ 登録して1週間以内ならNEWマークを返す ------------------------------------------------------------*/ function search_new($day) { $week = 7*24*3600; $registerdate = strtotime($day); $today = strtotime(date("Y-m-d H:i:s")); if (($today-$registerdate)<=$week) { return "New"; } } /*------------------------------------------------------------ ページの一覧 ------------------------------------------------------------*/ function page_info($page,$total,$p) { //リンク先 if ($_GET["c"]) { $lnk = "&c=".$_GET["c"]; } elseif ($_GET["m"]) { $lnk = "&m=".$_GET["m"]; } elseif ($_GET["b"]) { $lnk = "&b=".$_GET["b"]; } $all_page = ceil($total/$page); if ($p > 1) { //ページトップでない $str.="<<前へ....."; } for($i=1; $i<=$all_page; $i++) { if ($i==$p) { $str.="".$i." "; } else { $str.=<<{$i}  HTML; } } if ($p < $all_page) { //ページ最後尾でない $str.=".....次へ>>"; } return $str; } /*------------------------------------------------------------ パンくずリスト 階層無制限 ------------------------------------------------------------*/ function pankuzu($row) { if ($row["hierarchy"]==1) { $str = $row["category"]; } else { $tmp[] = $row["category"]; do { $row = get_pdo("category_tb","*",array("s_id"=>$row["o_id"])); $tmp[] = "".$row["category"]." "; } while ($row["hierarchy"]>1); //配列を逆にする $pan = array_reverse($tmp); $str = @implode("> ",$pan); } return $str; } ?>