묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
제로님이 쓰신 카운터 만들기에 대해서...
2004.05.12 16:20
소스를 다 합치니까 이렇게 되데요...
<?
$host_name = "localhost";
$user_name = "******";
$user_password = "******";
$db_name ="******";
$connect = mysql_connect($host_name,$user_name,$user_password);
mysql_select_db($db_name, $connect);
$result = mysql_list_tables ($db_name);
$i = 0;
$tablelist="";
while ($i < mysql_num_rows ($result))
{
$tb_names[$i] = mysql_tablename ($result, $i);
$tablelist .= "/".$tb_names[$i];
$i++;
}
if(!eregi("zerocount",$tablelist))
{
$que = "CREATE TABLE zerocount (
id int(11) DEFAULT '0' NOT NULL auto_increment,
count int(11),
date varchar(8),
PRIMARY KEY (id))";
mysql_query( $que, $connect );
}
$td=date("Ymd");
$que="select * from zerocount where id=1";
$result=mysql_query($que, $connect );
$check=mysql_fetch_array($result);
if(!$check[count])
{
$que = "INSERT INTO zerocount VALUES ('', 0, '')";
mysql_query($que, $connect );
}
$que="select * from zerocount where date='$td'";
$result=mysql_query($que, $connect );
$check=mysql_fetch_array($result);
if(!$check[count])
{
$que = "INSERT INTO zerocount VALUES ('', 0, '$td')";
mysql_query($que, $connect );
}
if($HTTP_COOKIE_VARS[zerocount]!=$td)
{
setcookie("zerocount",$td,time()+60*60*24);
$que = "update zerocount SET count=count+1 WHERE id=1";
$result=mysql_query($que, $connect );
$que = "update zerocount SET count=count+1 WHERE date='$td'";
$result=mysql_query($que, $connect );
}
$que="select * from zerocount where id=1"; // 전체
$result=mysql_query($que, $connect );
$temp=mysql_fetch_array($result);
$count[0]=$temp[count];
$que="select * from zerocount order by id desc limit 2"; // 오늘, 어제
$result=mysql_query($que, $connect );
$temp=mysql_fetch_array($result);
$count[1]=$temp[count]; // ---- 오늘꺼
$today_id=$temp[id];
$temp=mysql_fetch_array($result);
$count[2]=$temp[count];
$tempid=$temp[id]; // ------ 어제꺼
$que="select * from zerocount where id>1 order by count desc limit 1"; // 최고
$result=mysql_query($que, $connect );
$temp=mysql_fetch_array($result);
$count[3]=$temp[count];
$que="select * from zerocount where id<$today_id order by count limit 1"; // 최저
$result=mysql_query($que, $connect );
$temp=mysql_fetch_array($result);
$count[4]=$temp[count];
?>
오늘꺼 하려면 멀 해야 되나요...?
$count[0]는 전체고...
$count[1]이에요 $count[2]에요...?
답변좀 부탁드립니다~
아 그리구 이거 쿠키 시간으로 하는건가요... 아님 익스플로러 닫길때까지 인가요...?
<?
$host_name = "localhost";
$user_name = "******";
$user_password = "******";
$db_name ="******";
$connect = mysql_connect($host_name,$user_name,$user_password);
mysql_select_db($db_name, $connect);
$result = mysql_list_tables ($db_name);
$i = 0;
$tablelist="";
while ($i < mysql_num_rows ($result))
{
$tb_names[$i] = mysql_tablename ($result, $i);
$tablelist .= "/".$tb_names[$i];
$i++;
}
if(!eregi("zerocount",$tablelist))
{
$que = "CREATE TABLE zerocount (
id int(11) DEFAULT '0' NOT NULL auto_increment,
count int(11),
date varchar(8),
PRIMARY KEY (id))";
mysql_query( $que, $connect );
}
$td=date("Ymd");
$que="select * from zerocount where id=1";
$result=mysql_query($que, $connect );
$check=mysql_fetch_array($result);
if(!$check[count])
{
$que = "INSERT INTO zerocount VALUES ('', 0, '')";
mysql_query($que, $connect );
}
$que="select * from zerocount where date='$td'";
$result=mysql_query($que, $connect );
$check=mysql_fetch_array($result);
if(!$check[count])
{
$que = "INSERT INTO zerocount VALUES ('', 0, '$td')";
mysql_query($que, $connect );
}
if($HTTP_COOKIE_VARS[zerocount]!=$td)
{
setcookie("zerocount",$td,time()+60*60*24);
$que = "update zerocount SET count=count+1 WHERE id=1";
$result=mysql_query($que, $connect );
$que = "update zerocount SET count=count+1 WHERE date='$td'";
$result=mysql_query($que, $connect );
}
$que="select * from zerocount where id=1"; // 전체
$result=mysql_query($que, $connect );
$temp=mysql_fetch_array($result);
$count[0]=$temp[count];
$que="select * from zerocount order by id desc limit 2"; // 오늘, 어제
$result=mysql_query($que, $connect );
$temp=mysql_fetch_array($result);
$count[1]=$temp[count]; // ---- 오늘꺼
$today_id=$temp[id];
$temp=mysql_fetch_array($result);
$count[2]=$temp[count];
$tempid=$temp[id]; // ------ 어제꺼
$que="select * from zerocount where id>1 order by count desc limit 1"; // 최고
$result=mysql_query($que, $connect );
$temp=mysql_fetch_array($result);
$count[3]=$temp[count];
$que="select * from zerocount where id<$today_id order by count limit 1"; // 최저
$result=mysql_query($que, $connect );
$temp=mysql_fetch_array($result);
$count[4]=$temp[count];
?>
오늘꺼 하려면 멀 해야 되나요...?
$count[0]는 전체고...
$count[1]이에요 $count[2]에요...?
답변좀 부탁드립니다~
아 그리구 이거 쿠키 시간으로 하는건가요... 아님 익스플로러 닫길때까지 인가요...?