|
|
|
ช่วยด้วยครับ ผมทำระบบ Counter ให้นับแยกหน้าไม่ได้ครับ ท่านผู็เชี่ยวชาญทั้งหลายช่วยทีครับ |
|
|
|
|
|
|
|
รบกวนท่านผู้รู้ช่วยทีครับ ผมสร้างไฟล์ news_Event.php แล้วส่งลิ๊งค์ไปหน้า event_detail.php ผมวาง Counter ไว้ที่หน้านี้น่ะครับ
แต่ผมไม่สามารถ ให้มันนับแยกทีละข้อมูลข่าวสารนั้นๆ ได้ครับ มันนับรวมๆ กันครับ
ไฟล์ event_detail.php
Code (PHP)
<? include ("include.php"); ?>
<? include ("gen_load_detail.php"); ?>
<?
ob_start();
$page = "event_detail.php";
?>
<?php
require_once('counter/counter.php');
do_counter_hit('1');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<LINK rel="shortcut icon" href="http://www.laemtech.ac.th/favicon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>วิทยาลัยเทคโนโลยีแหลมทอง - ข่าสสาร และ กิจกรรมของเรา</title>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function findPos() {
obj = document.img_about;
var left = !!obj.offsetLeft ? obj.offsetLeft : 0;
while(obj = obj.offsetParent) {
left += !!obj.offsetLeft ? obj.offsetLeft : 0;
}
return left;
}
function getPos(){
if(document.all)e = event;
var obj = document.getElementById('Layer1');
var leftPos = findPos();
obj.style.left = leftPos + 'px';
// obj.style.top = top+'px';
}
//-->
</script>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-23891122-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function findPos() {
obj = document.img_about;
var left = !!obj.offsetLeft ? obj.offsetLeft : 0;
var top = !!obj.offsetTop ? obj.offsetTop : 0;
while(obj = obj.offsetParent) {
left += !!obj.offsetLeft ? obj.offsetLeft : 0;
top += !!obj.offsetTop ? obj.offsetTop : 0;
}
return top;
}
function getPos(){
if(document.all)e = event;
var obj = document.getElementById('Layer1');
var leftPos = findPos()-140;
obj.style.top = leftPos + 'px';
// obj.style.top = top+'px';
}
//-->
</script>
<link href="css/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
a:link {
color: #000000;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
color: #FF6600;
}
a:active {
text-decoration: none;
color: #000000;
}
.style1 {color: #FFFFFF}
.style2 {color: #CCCCCC}
.style3 {font-size: 9px}
.style4 {font-size: 10px}
-->
</style>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:300;
height:100px;
z-index:1;
top: 793px;
left: 824px;
}
#Layer2 {position:absolute;
width:998px;
height:64px;
z-index:1;
}
#Layer3 {position:absolute;
width:300px;
height:50px;
z-index:1;
}
-->
</style>
<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body>
<table width="100%" hight="800 pixel" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" background="images/BgHeader.gif"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="30%"><a href="index.php"><img src="images/laemtech_logo_head.png" width="440" height="50" border="0" /></a></td>
<td width="37%"> </td>
<td width="33%"><div align="center" class="style1">
<div align="right">
<div align="center" class="style1">
<div align="right">Tel. 02-581-5548 Fax. 02-978-2844</div>
</div>
</div>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="826" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="83"><a href="index.php"><img src="images/Main_Menu/Mennu_Button/Main_Menu_01.gif" alt="หน้าหลัก" width="83" height="30" border="0" /></a></td>
<td width="91"><a href="institute.php"><img src="images/Main_Menu/Mennu_Button/Main_Menu_02.gif" alt="ข้อมูลสถาบัน" width="91" height="30" border="0" /></a></td>
<td width="81"><a href="teachers.php"><img src="images/Main_Menu/Mennu_Button/Main_Menu_03.gif" alt="คณาจารย์" width="81" height="30" border="0" /></a></td>
<td width="79"><a href="course.php"><img src="images/Main_Menu/Mennu_Button/Main_Menu_04.gif" alt="หลักสูตร" width="79" height="30" border="0" /></a></td>
<td width="82"><a href="apply.php"><img src="images/Main_Menu/Mennu_Button/Main_Menu_05.gif" alt="สมัครเรียน" width="82" height="30" border="0" /></a></td>
<td width="120"><a href="news_event.php"><img src="images/Main_Menu/Mennu_Button/Main_Menu_06.gif" alt="ข่าวสาร-กิจกรรม" width="120" height="30" border="0" /></a></td>
<td width="95"><a href="download.php"><img src="images/Main_Menu/Mennu_Button/Main_Menu_09.jpg" alt="ดาวน์โหลด" width="95" height="30" border="0" /></a></td>
<td width="81"><a href="contact.php"><img src="images/Main_Menu/Mennu_Button/Main_Menu_07.gif" alt="ติดต่อเรา" width="81" height="30" border="0" /></a></td>
<td width="114"><div align="left"><a href="sitemap.php"><img src="images/Main_Menu/Mennu_Button/Main_Menu_08.gif" alt="แผนผังเว็บไซต์" width="113" height="30" border="0" /></a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="27" valign="top"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><img src="images/Head_Bannner/News_Event.jpg" width="900" height="318" border="0"></td>
</tr>
<tr>
<td valign="top"><table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="257" valign="top"><table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/Thumbnail_Banner/News_Event.jpg" width="250" height="129" border="0"></td>
</tr>
<tr>
<td><table width="250" border="0" align="center">
<tr>
<td width="32"><div align="left"><a href="news_event.php"></a><img src="images/Icon/Airrow.gif" width="31" height="19" border="0"></div></td>
<td width="178"><div align="left"><a href="news_event.php">ข่าวสาร - กิจกรรม</a></div></td>
</tr>
<tr>
<td><div align="left"><img src="images/Icon/Airrow.gif" width="31" height="19" border="0"></div></td>
<td><div align="left"><a href="special_benefits.php">สวัสดิการพิเศษฯ</a></div></td>
</tr>
<tr>
<td><div align="left"><img src="images/Icon/Airrow.gif" width="31" height="19" border="0"></div></td>
<td><div align="left"><a href="http://www.studentloan.or.th/index.php" target="_blank">ข่าวสาร กยศ.</a></div></td>
</tr>
<tr>
<td><div align="left"><img src="images/Icon/Airrow.gif" width="31" height="19" border="0"></div></td>
<td><div align="left"><a href="Special_Scholarship.php">ทุนการศึกษาพิเศษจากสถาบันฯ</a></div></td>
</tr>
<tr>
<td><div align="left"><img src="images/Icon/Airrow.gif" width="31" height="19" border="0"></div></td>
<td><div align="left"><a href="social_responsibility.php">กิจกรรมเพื่อสังคม</a></div></td>
</tr>
<tr>
<td><img src="images/Icon/Airrow.gif" width="31" height="19" border="0"></td>
<td><div align="left"><a href="gallery_center.php">Gallery Center</a></div></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="643" valign="top"><? $display = "none"; ?>
<body onLoad="MM_preloadImages('images/icon_language_th2.gif'); getPos()"> <kJNPAGyUfwlpmhli1o6kENwBUZTINEoUZ5KH6vuxrkQU5></kJNPAGyUfwlpmhli1o6kENwBUZTINEoUZ5KH6vuxrkQU5>
<table width="651" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="651"><table border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><table border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"> </td>
<td valign="top">
<?
$cmd = new cmdSQL;
$cmd->SetTb("tbnews");
$sWhere = "iEnable=1 and id=".$_REQUEST['id'];
$cmd->SelectCond($sWhere);
$totalRecord = $cmd->GetTotalRecord();
if ($totalRecord > 0) {
while ($cmd->Loop()) {
$sImg2 = ($cmd->GetValue("sFilename2")) ? $cmd->GetValue("sFilename2") : "";
$sImg3 = ($cmd->GetValue("sFilename3")) ? $cmd->GetValue("sFilename3") : "";
$sImg4 = ($cmd->GetValue("sFilename4")) ? $cmd->GetValue("sFilename4") : "";
$sImg5 = ($cmd->GetValue("sFilename5")) ? $cmd->GetValue("sFilename5") : "";
$oldurl = "../uploadfiles/files/";
$newurl = C_HTMLAREA;
$tNewDetail = str_replace($oldurl, $newurl, $cmd->GetValue("tDetailEn"));
$oldurl = "../_admin/uploadfiles/files/";
$newurl = C_HTMLAREA;
$tNewDetail = str_replace($oldurl, $newurl, $tNewDetail);
?>
<table width="631" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td height="53" colspan="2" background="images/Icon/BG_News_Event.jpg" style="background-repeat:no-repeat;"><script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width', '630','height','52','src','event_detail_th','quality','high','pluginspage', 'http://www.macromedia.com/go/getflashplayer','wmode','transparent','movie','event_detail_th' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="630" height="52">
<param name="movie" value="event_detail_th.swf" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<embed src="event_detail_th.swf" width="630" height="52" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>
</object>
</noscript></td>
</tr>
<tr>
<td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="5%" valign="top"> </td>
<td width="3%" valign="top"><img src="images/clear.gif" width="20" height="1"></td>
<td width="92%" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
<tr>
<td background="images/dot.gif"><img src="images/clear.gif" width="1" height="3"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><?=$tNewDetail?>
<div id="Layer1" style="position:absolute; display:<?=$display?>;">
<table width="280" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td> </td>
</tr>
<tr>
<td align="right"><a href="javascript:;" onClick="Layer1.style.display='none'" class="link">(close x</a>) </td>
</tr>
<tr>
<td><iframe src="mail2friend.php?id=<?=$_REQUEST['id']?>" name="mail" width="100%" height="100" scrolling="No" frameborder="0" id="mail"></iframe></td>
</tr>
</table></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td background="images/dot.gif"><img src="images/clear.gif" width="1" height="3"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><? if ($sImg2 || $sImg3) { ?><table border="0" cellpadding="0" cellspacing="0">
<tr>
<? if ($sImg2) {
list($width, $height, $type, $attr) = getimagesize("_admin/uploadfiles/".$sImg2);
if ($width > 1000) {
$width = 1000;
} else {
$width = $width+20;
}
if ($height > 700) {
$height = 700;
} else {
$height = $height+5;
}
?>
<td valign="top"><table border="0" cellpadding="0" cellspacing="2" bgcolor="#E5E5E5">
<tr>
<td><img src="libs/resize.php?img=../_admin/uploadfiles/<?=$sImg2?>" onClick="MM_openBrWindow('event_popup.php?img=<?=$sImg2?>','view','scrollbars=yes,width=<?=$width?>,height=<?=$height?>')" style="cursor: hand;"></td>
</tr>
</table></td>
<? } ?>
<td><img src="images/clear.gif" width="40" height="1"></td>
<? if ($sImg3) {
list($width, $height, $type, $attr) = getimagesize("_admin/uploadfiles/".$sImg3);
if ($width > 1000) {
$width = 1000;
} else {
$width = $width+20;
}
if ($height > 700) {
$height = 700;
} else {
$height = $height+20;
}
?>
<td valign="top"><table border="0" cellpadding="0" cellspacing="2" bgcolor="#E5E5E5">
<tr>
<td><img src="libs/resize.php?img=../_admin/uploadfiles/<?=$sImg3?>" onClick="MM_openBrWindow('event_popup.php?img=<?=$sImg3?>','view','scrollbars=yes,width=<?=$width?>,height=<?=$height?>')" style="cursor: hand;"></td>
</tr>
</table></td>
<? } ?>
</tr><tr>
</tr><tr>
<td height="40" colspan="3"> </td>
</tr>
<? if ($sImg4) {
list($width, $height, $type, $attr) = getimagesize("_admin/uploadfiles/".$sImg4);
if ($width > 1000) {
$width = 1000;
} else {
$width = $width+20;
}
if ($height > 700) {
$height = 700;
} else {
$height = $height+20;
}
?>
<tr><td valign="top"><table border="0" cellpadding="0" cellspacing="2" bgcolor="#E5E5E5">
<tr>
<td><img src="libs/resize.php?img=../_admin/uploadfiles/<?=$sImg4?>" onClick="MM_openBrWindow('event_popup.php?img=<?=$sImg4?>','view','scrollbars=yes,width=<?=$width?>,height=<?=$height?>')" style="cursor: hand;"></td>
</tr>
</table></td>
<? } ?>
<td><img src="images/clear.gif" width="40" height="1"></td>
<? if ($sImg5) {
list($width, $height, $type, $attr) = getimagesize("_admin/uploadfiles/".$sImg5);
if ($width > 1000) {
$width = 1000;
} else {
$width = $width+20;
}
if ($height > 700) {
$height = 700;
} else {
$height = $height+20;
}
?>
<td valign="top"><table border="0" cellpadding="0" cellspacing="2" bgcolor="#E5E5E5">
<tr>
<td><img src="libs/resize.php?img=../_admin/uploadfiles/<?=$sImg5?>" onClick="MM_openBrWindow('event_popup.php?img=<?=$sImg5?>','view','scrollbars=yes,width=<?=$width?>,height=<?=$height?>')" style="cursor: hand;"></td>
</tr>
</table></td>
<? } ?>
</tr>
</table>
<? } ?> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align="left">จำนวนผู้เข้าชม : <?php include('counter_text/counter.php'); ?></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2" background="images/dot.gif"><img src="images/clear.gif" width="1" height="3"></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="410"><a href="javascript:history.go(-1)"><img src="images/icon_back_01.gif" width="77" height="24" border="0"></a></td>
<td width="221" align="right"><a href="javascript:;" onClick="Layer1.style.display='block'"><img src="images/send_this_page.gif" name="img_about" width="221" height="24" border="0" id="img_about"></a></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
<?
}
} else {
echo "There are no record found.";
}
?> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table> </td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="113" valign="top" background="images/BgFooter.gif"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="225"> </td>
<td width="240"> </td>
<td width="237"> </td>
<td width="198"><div align="right"><img src="images/Main_Menu/Contact_Us.jpg" alt="ติดต่อเรา" width="194" height="25" border="0"></div></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="3"><table width="541" border="0" align="left">
<tr>
<td width="174"><a href="images/Location_Map/Laemtech_Map.jpg" target="_blank">Location & Map</a></td>
<td width="201"><a href="#" onclick="MM_openBrWindow('e-newsletter.php','','width=350,height=200')">Laemtech Newsletter</a></td>
<td width="152"><a href="webmaster.php">ติดต่อ Webmaster</a></td>
</tr>
</table></td>
<td valign="top"><table width="121" border="0" align="center">
<tr>
<td width="35"><a href="social_network.php"><img src="images/Contact_Icon_01.png" width="30" height="29" border="0"></a></td>
<td width="36"><a href="social_network.php"><img src="images/Contact_Icon_02.png" width="30" height="29" border="0"></a></td>
<td width="39"><a href="social_network.php"><img src="images/Contact_Icon_03.png" width="30" height="29" border="0"></a></td>
<td width="52"><a href="social_network.php"><img src="images/Contact_Icon_04.png" width="30" height="26" border="0"></a></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="4"><div align="left"><img src="images/Icon/Coppyright.jpg" width="332" height="30" border="0"></div>
<div align="left"></div>
<div align="left"></div></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
<? $cmd->Freeresult(); ?>
<? include ("initial/disconnect.php"); ?>
ไฟล์ counter.php
<?php
$filename = "PHPCounter.txt";
//$fp = fopen( $filename,"r");
//$Old = fread($fp, 100);
//fclose( $fp );
$Old = split ("=", $Old, 5);
$NewCount = $Old[1] + '1';
$New = "Count=$NewCount";
//$fp = fopen( $filename,"w+");
//if (flock($fp, 2)) {
//fwrite($fp, $New, 100); }
//fclose( $fp );
print " ¨Ó¹Ç¹¤ÃÑ駷Õèà¢éÒªÁ = $NewCount";
?>
ไฟล์ PHPCounter.txt
เป็นไฟล์ TEXT เปล่าๆ ครับ
ดูตัวอย่างไฟล์ได้ที่
http://www.laemtech.ac.th/news_event.php
http://www.laemtech.ac.th/event_detail.php?id=30
และตรงหน้าแรก
http://www.laemtech.ac.th/index.php
ผมอยากให้มันแสดงผลรวมของหัวข้อข่าวทั้งหมดครับ ว่ามีทั้งหมดกี่หัวข้อครับ
รบกวนด้วยนะครับ
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2011-06-15 17:59:26 |
By :
sawaschai |
View :
1361 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
สร้าง column ในตาราง news แล้ว update +1 ทุกครั้งที่มีการเปิดก็ได้ครับ
|
|
|
|
|
Date :
2011-06-16 08:58:08 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมอยากทำแบบที่ไม่ต้องสร้างฐานข้อมูลน่ะครับ จะได้ใช้งานหลากหลายครับ มีใครทราบมั่งครับว่าต้องทำยังไง
|
|
|
|
|
Date :
2011-06-16 10:18:56 |
By :
sawaschai |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|