묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
카운터를 만들었는데요
2003.08.30 13:05
방문객 수가 올라가질 않습니다.
<?
$host_name = "XXXX";
$user_name = "XXXX";
$user_password = "XXXX";
$db_name ="XXXX";
$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("counter",$tablelist))
{
$que = "CREATE TABLE counter (
id int(11) DEFAULT '0' NOT NULL auto_increment,
count int(11),
date varchar(8),
PRIMARY KEY (id))";
mysql_query( $que, $connect );
}
$today=date("ymd");
$que="select * from counter where id=1";
$result=mysql_query($que, $connect );
$check=mysql_fetch_array($result);
if(!$check[count])
{
$que = "INSERT INTO counter VALUES ('', 0, '')";
mysql_query($que, $connect );
}
$que="select * from counter where date='$td'";
$result=mysql_query($que, $connect );
$check=mysql_fetch_array($result);
if(!$check[count])
{
$que = "INSERT INTO counter VALUES ('', 0, '$td')";
mysql_query($que, $connect );
}
if($HTTP_COOKIE_VARS[zerocount]!=$td)
{
setcookie("counter",$td,time()+60*60*24);
$que = "update counter SET count=count+1 WHERE id=1";
$result=mysql_query($que, $connect );
$que = "update counter SET count=count+1 WHERE date='$td'";
$result=mysql_query($que, $connect );
}
$que="select * from counter where id=1"; // 전체
$result=mysql_query($que, $connect );
$temp=mysql_fetch_array($result);
$count[0]=$temp[count];
$que="select * from counter 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 counter 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 counter where id<$today_id order by count limit 1"; // 최저
$result=mysql_query($que, $connect );
$temp=mysql_fetch_array($result);
$count[4]=$temp[count];
?>
<table border="1" cellpadding="0" cellspacing="1" bordercolor="#000000" bgcolor="#999999">
<tr>
<td bordercolor="#CCCCCC"><font color="#333333" size="2">총 방문객 수 </font><font color="FFFFFF"><? echo "$count[0]"; ?></font></td>
</tr>
<tr>
<td height="20" bordercolor="#CCCCCC"><font color="#333333" size="2">오늘 방문객
수</font> <font color="FFFFFF"><? echo "$count[2]"; ?></font></td>
</tr>
<tr>
<td height="20" bordercolor="#CCCCCC"><font color="#333333" size="2">최고 방문객
수</font> <font color="FFFFFF"><? echo "$count[3]"; ?></font></td>
</tr>
<tr>
<td height="20" bordercolor="#CCCCCC"><font color="#333333" size="2">최저 방문객
수</font> <font color="FFFFFF"><? echo "$count[4]"; ?></font></td>
</tr>
</table>
이렇게 작성을 했는데요.
main.html에 인클루드를 써서 테이블안에 집어넣었는데
테이블은 정상적으로 나오는데 카운터가 올라가질 않습니다.
잘못된 점이 있으면 꼬집어 주시길 바래요 -ㅂ-);;;*(퍽!!)
눈이 나빠서 @_@;
<?
$host_name = "XXXX";
$user_name = "XXXX";
$user_password = "XXXX";
$db_name ="XXXX";
$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("counter",$tablelist))
{
$que = "CREATE TABLE counter (
id int(11) DEFAULT '0' NOT NULL auto_increment,
count int(11),
date varchar(8),
PRIMARY KEY (id))";
mysql_query( $que, $connect );
}
$today=date("ymd");
$que="select * from counter where id=1";
$result=mysql_query($que, $connect );
$check=mysql_fetch_array($result);
if(!$check[count])
{
$que = "INSERT INTO counter VALUES ('', 0, '')";
mysql_query($que, $connect );
}
$que="select * from counter where date='$td'";
$result=mysql_query($que, $connect );
$check=mysql_fetch_array($result);
if(!$check[count])
{
$que = "INSERT INTO counter VALUES ('', 0, '$td')";
mysql_query($que, $connect );
}
if($HTTP_COOKIE_VARS[zerocount]!=$td)
{
setcookie("counter",$td,time()+60*60*24);
$que = "update counter SET count=count+1 WHERE id=1";
$result=mysql_query($que, $connect );
$que = "update counter SET count=count+1 WHERE date='$td'";
$result=mysql_query($que, $connect );
}
$que="select * from counter where id=1"; // 전체
$result=mysql_query($que, $connect );
$temp=mysql_fetch_array($result);
$count[0]=$temp[count];
$que="select * from counter 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 counter 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 counter where id<$today_id order by count limit 1"; // 최저
$result=mysql_query($que, $connect );
$temp=mysql_fetch_array($result);
$count[4]=$temp[count];
?>
<table border="1" cellpadding="0" cellspacing="1" bordercolor="#000000" bgcolor="#999999">
<tr>
<td bordercolor="#CCCCCC"><font color="#333333" size="2">총 방문객 수 </font><font color="FFFFFF"><? echo "$count[0]"; ?></font></td>
</tr>
<tr>
<td height="20" bordercolor="#CCCCCC"><font color="#333333" size="2">오늘 방문객
수</font> <font color="FFFFFF"><? echo "$count[2]"; ?></font></td>
</tr>
<tr>
<td height="20" bordercolor="#CCCCCC"><font color="#333333" size="2">최고 방문객
수</font> <font color="FFFFFF"><? echo "$count[3]"; ?></font></td>
</tr>
<tr>
<td height="20" bordercolor="#CCCCCC"><font color="#333333" size="2">최저 방문객
수</font> <font color="FFFFFF"><? echo "$count[4]"; ?></font></td>
</tr>
</table>
이렇게 작성을 했는데요.
main.html에 인클루드를 써서 테이블안에 집어넣었는데
테이블은 정상적으로 나오는데 카운터가 올라가질 않습니다.
잘못된 점이 있으면 꼬집어 주시길 바래요 -ㅂ-);;;*(퍽!!)
눈이 나빠서 @_@;