[쇼핑몰] 기간별 히트상품 뽑기
페이지 정보
본문
특정 기간동안의 히트상품을 뽑아옵니다
item.php
<?
sql_query("CREATE TABLE if not exists `yc4_item_hit` (
`date` DATE NOT NULL ,
`it_id` varchar(10) NOT NULL default '',
`ca_id` varchar(10) NOT NULL default '0',
`ca_id2` varchar(255) NOT NULL default '',
`ca_id3` varchar(255) NOT NULL default '',
`it_name` varchar(255) NOT NULL default '',
`it_opt1` text NOT NULL,
`it_opt2` text NOT NULL,
`it_opt3` text NOT NULL,
`it_opt4` text NOT NULL,
`it_opt5` text NOT NULL,
`it_opt6` text NOT NULL,
`it_amount` int(11) NOT NULL default '0',
`it_use` tinyint(4) NOT NULL default '0',
`hit` INT NOT NULL ,
`ip_list` TEXT NOT NULL)");
$date = $g4[time_ymd];
if($temp = sql_fetch("select ip_list from `yc4_item_hit` where date='$date' AND it_id='$it_id'")) {
if(!strstr($temp[ip_list], "/".$_SERVER[REMOTE_ADDR]."/")) {
sql_query("update `yc4_item_hit` set hit = it_hit + 1, ip_list = CONCAT(ip_list, '{$_SERVER[REMOTE_ADDR]}', '/') where date='$date' AND ca_id='$ca_id' AND ca_id2='$ca_id2' AND ca_id3='$ca_id3' AND it_name='$it[it_name]' AND it_opt1='$it[it_opt1]' AND it_opt2='$it[it_opt2]' AND it_opt3='$it[it_opt3]' AND it_opt4='$it[it_opt4]' AND it_opt5='$it[it_opt5]' AND it_opt6='$it[it_opt6]' AND it_amount='$it[it_amount]' and it_use='$it[it_use]' AND it_id='$it_id' LIMIT 1");
}
}
else {
sql_query("insert into `yc4_item_hit` set date='$date', ca_id='$ca_id', ca_id2='$ca_id2', ca_id3='$ca_id3', it_name='$it[it_name]', it_opt1='$it[it_opt1]', it_opt2='$it[it_opt2]', it_opt3='$it[it_opt3]', it_opt4='$it[it_opt4]', it_opt5='$it[it_opt5]', it_opt6='$it[it_opt6]', it_amount='$it[it_amount]', it_use='$it[it_use]', it_id='$it[it_id]', hit='1', ip_list='/{$_SERVER[REMOTE_ADDR]}/'");
}
?>
lib/shop.lib.php
//hit
function display_hitcategory($no, $list_mod, $list_row, $img_width, $img_height, $ca_id="")
{
global $member, $g4;
// 상품수
/*
$items = $list_mod * $list_row;
//$sql = " select * from $g4[yc4_item_table] where it_use = '1' and it_time > date_add(now(), interval -7 day)";
$sql = " select * from $g4[yc4_item_table] where it_use = '1'";
if ($ca_id)
$sql .= " and ca_id LIKE '{$ca_id}%'";
$sql .= " order by it_hit desc limit $items ";
$result = sql_query($sql);
if (!mysql_num_rows($result)) {
return false;
}
*/
// 상품수
$items = $list_mod * $list_row;
//$sql = " select * from $g4[yc4_item_table] where it_use = '1' and it_time > date_add(now(), interval -7 day)";
// $sql = " select * from $g4[yc4_item_table] where it_use = '1'";
$sql = "select * from `yc4_item_hit` where date >= (curdate() - interval 7 day)";
if ($ca_id)
$sql .= " AND ca_id LIKE '{$ca_id}%' GROUP BY ca_id LIKE '{$ca_id}%', it_id";
$sql .= " ORDER BY sum(hit) desc limit $items ";
$result = sql_query($sql);
if (!mysql_num_rows($result)) {
return false;
}
$file = "$g4[shop_path]/maintype{$no}.inc.php";
if (!file_exists($file)) {
echo "<span class=point>{$file} 파일이 없습니다.</span>";
} else {
$td_width = (int)(100 / $list_mod);
include $file;
}
}
head.php
<?
$type = 1;
display_hitcategory("z20", 1, 5, 55, 55, "90");
?>
90은ca_id
특정함수 추가시 전체 추가해줘야 작동합니다..
링크자료의 그누보드 함수를 참고하였습니다
첨부파일
-
m3_latest_popular_utf8.zip (2.3K)
3회 다운로드 | DATE : 2009-06-27 04:20:45
관련링크
댓글목록
등록된 댓글이 없습니다.