|
 |
|
ถามเรื่องโค้ดcounter หน่อยค่ะ คือว่าเขียนโค้ดนับจำนวนผู้เข้าชมทั้งหมดค่ะแต่พอกด refresh แล้วจำนวนก็เพิ่มอ่ะค่ะต้องเพิ่มโค้ดอย่างไรค่ะ |
|
 |
|
|
 |
 |
|
แก้เป็น
Code (PHP)
<?
$filename="number.txt";
$fp=fopen($filename,"r");
$get_number=fread($fp,filesize($filename));
fclose($fp);
session_start();
if(!$_SESSION['check_sess']){
$_SESSION['check_sess']=session_id();
$get_number=$get_number+1;
}
$fp=fopen($filename,"w";
fwrite($fp,$get_number);
fclose($fp);
$counter=sprintf("%05d",$get_number);
for($i=0;$i<5;$i++){
echo"<img src='images/$gcounter[$i].gif'>";
}
?>
น่าจะได้นะ ลองดู(ยังไม่ได้รัน)
ถ้าได้บอกด้วยนะ
|
 |
 |
 |
 |
Date :
2010-02-27 00:03:32 |
By :
onedan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองใส่ตามแล้วค่ะมันก็ยังเพิ่มอยู่เวลาเรากดรีเฟรชอ่ะค่ะ
Code (PHP)
<?
$file="counter/counter.txt";
$open1=fopen($file,"r");
$get_number=fread($open1,filesize($file));
fclose($open1);
session_start();
if(!$_SESSION['check_sess']){
$_SESSION['check_sess']=session_id();
$get_number=$get_number+1;
}
$get_number=$get_number+1;
$open2=fopen($file,"w");
fwrite($open2,$get_number);
fclose($open2);
$digit=sprintf("%06d",$get_number);
for($i=0;$i<6;$i++){
echo"<img src='counter/images/$digit[$i].gif'/>";
}
?>
|
 |
 |
 |
 |
Date :
2010-02-27 02:24:30 |
By :
axiom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2010-02-27 12:47:03 |
By :
axiom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังแก้ไม่ได้เลย
|
 |
 |
 |
 |
Date :
2010-02-27 16:24:40 |
By :
axiom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?
$filename="number.txt";
$fp=fopen($filename,"r");
$get_number=fread($fp,filesize($filename));
fclose($fp);
if(!isset($_SESSION['NO_REFRESH'])
{
$get_number=$get_number+1;
$fp=fopen($filename,"w";
fwrite($fp,$get_number);
fclose($fp);
}
$counter=sprintf("%05d",$get_number);
for($i=0;$i<5;$i++){
echo"<img src='images/$gcounter[$i].gif'>";
}
?>
|
 |
 |
 |
 |
Date :
2010-02-27 20:47:30 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วค่ะขอบคุณมาก
|
 |
 |
 |
 |
Date :
2010-02-28 00:07:50 |
By :
axiom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอ code ฐานข้อมูลหน่อยคับ
|
 |
 |
 |
 |
Date :
2010-09-09 19:41:11 |
By :
sek |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พอดีผมพึ่งหัดเขียนนะคับ รบกวนท่านผู้รู้นิดนึงนะครับ จาก Code ด้านบน ผมอยากทราบว่าเราจะนำไปวางอย่างไรใน HTML หรือใน Dream ผมพยายามแล้วแต่ไม่สำเร็จรบกวนหน่อยนะครับ ขอบคุณล่วงหน้าเลยครับ     
|
 |
 |
 |
 |
Date :
2010-12-25 06:38:58 |
By :
กรณ์โชตน์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พอดีผมพึ่งหัดเขียนนะคับ รบกวนท่านผู้รู้นิดนึงนะครับ จาก Code ด้านบน ผมอยากทราบว่าเราจะนำไปวางอย่างไรใน HTML หรือใน Dream ผมพยายามแล้วแต่ไม่สำเร็จรบกวนหน่อยนะครับ ขอบคุณล่วงหน้าเลยครับ     
|
 |
 |
 |
 |
Date :
2010-12-25 06:39:35 |
By :
กรณ์โชตน์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใส่ <? ?>ระหว่างแท็ก html ครับ
|
 |
 |
 |
 |
Date :
2010-12-25 09:47:05 |
By :
Dragons_first |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
นี่แหละที่ีต้องการเลย..55+ขอบคุณมากจ้า
|
 |
 |
 |
 |
Date :
2010-12-25 12:35:18 |
By :
poopui |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ว่าแต่ว่านำไปเก็บไป txt ใช่หรือเปล่า ไม่ได้เก็บลง MySQL ใช่ไหม
เพราะแทรกไปแล้วสร้าง number.txt แล้วมันฟ้อง Parse error: syntax error, unexpected '{' in C:\AppServ\wwwฃ.......
|
 |
 |
 |
 |
Date :
2010-12-25 12:37:05 |
By :
poopui |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยดูของผมหน่อยครับ คือว่าผมเก็บเป็นไฟล์ .dat
มันไม่ขึ้นตัวเลขให้เลยอะครับ แบบว่ามันไม่ยอมเรียกไฟล์รูปที่เป็นตัวเลขขึ้นแสดง
แต่ในไฟล์ .dat มันก็ยังเก็บอยู่นะครับ
รบกวนด้วยครับ
Code (PHP)
<?php
$style = "images";
$height = "30";
$width = "30";
$hitsfile = "counter.dat";
$images = dirname( __FILE__ )."/images";
$images = str_replace( $DOCUMENT_ROOT,"",$images );
if ( file_exists( $hitsfile ) )
{
$hits = file( $hitsfile );
$hits = $hits[0] + 1;
$fp = fopen( $hitsfile, "w" );
fwrite( $fp, $hits );
fclose( $fp );
}
else
{
$fp = fopen( $hitsfile, "w" );
fwrite( $fp, "1" );
fclose( $fp );
$hits = 1;
}
if ( $style == "text" )
echo $hits;
else
{
$digit = "0000000" . strval( $hits );
$digit = substr( $digit, -7 );
for ( $i = 0; $i < strlen( $digit ); $i++ )
echo "<img src=$images/$digit[$i].gif height=$height width=$width alt=$hits>";
}
?>
|
 |
 |
 |
 |
Date :
2010-12-26 11:42:22 |
By :
kamuro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พี่ผู้กูรูผู้รู้คะ หนูเขียนเว็บด้วย html อ่ะค่ะ แต่หนูอยากได้ counter นับจำนวนโดยที่ไม่ต้องกดรีเฟรช อ่ะ แล้วหนูก็ลองนำโค้ด ข้างบน มาลองแปะในโค้ดหนูดู มันไม่เกิดผลลัพธ์ตามต้องการอ่ะ รบกวนพี่กูรู พิจารณาและบอกหนูหน่อยนะคะ ขอบพระคุณค่ะ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>Main</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<link rel="stylesheet" href="../Graphic/mm_travel2.css" type="text/css" />
<style type="text/css">
<!--
a:link {
color: #3366CC;
text-decoration: none;
}
a:hover {
color: #3366CC;
text-decoration: underline;
}
a:visited {
text-decoration: none;
color: #3366CC;Code (PHP)
[sub][/sub]
}
a:active {
text-decoration: none;
}
body,td,th {
font-size: 24px;
}
.style1 {
color: #FF9900;
font-weight: bold;
}
.style2 {color: #FF6600}
.style3 {color: #FFCC00}
-->
</style></head>
<body bgcolor="#C0DFFD">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#3366CC">
<td width="382" rowspan="3" nowrap="nowrap"><img src="../Graphic/mm_travel_photo.jpg" alt="Header image" width="382" height="127" border="0" /></td>
<td width="378" height="63" align="center" valign="bottom" nowrap="nowrap" id="logo"><strong>เทคนิคการดึงความรู้ปฏิบัติ</strong></td>
<td height="63" rowspan="2"></td>
</tr>
<tr bgcolor="#3366CC">
<td height="64" rowspan="2" align="center" valign="top" nowrap="nowrap" id="logo"><strong>จากคนทำงาน</strong></td>
</tr>
<tr bgcolor="#3366CC">
<td height="64"> </td>
</tr>
<tr>
<td colspan="3" bgcolor="#003366"><img src="../Graphic/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
</tr>
<tr bgcolor="#CCFF99">
<td height="25" colspan="3"> </td>
</tr>
<tr>
<td colspan="3" bgcolor="#003366"><img src="../Graphic/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
</tr>
</table>
<table width="760" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="40"> </td>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" class="pageName"> </td>
</tr>
<tr>
<td colspan="3" class="pageName"><strong>อบรมเชิงปฏิบัติการ</strong></td>
</tr>
<tr>
<td colspan="3" class="pageName"><strong>เทคนิคการดึงความรู้ปฏิบัติจากคนทำงาน</strong><br />
<strong>(Success story teller and Note taker)</strong></td>
</tr>
<tr>
<td colspan="3" class="subHeader">วันที่ 22-23 กันยายน 2554 <br />
ณ.เนเชอรัลบีช รีสอร์ท อ.แหลมสิงห์ จ.จันทบุรี</td>
</tr>
<tr>
<td width="409" align="center" class="bodyText"><span class="subHeader"><img src="../Photo/DSC00933.jpg" alt="large product photo" width="333" height="250" border="0" /></span></td>
<td width="15" class="bodyText"> </td>
<td width="363" valign="bottom" class="bodyText"><p><span class="subHeader">สรุปสาระจากการฝึกอบรม</span><br />
<a href="bar.html">1.กิจกรรม BAR (Before Action Review)</a><br />
<a href="ฟัง ฟัง ฟัง.html">2.ฟัง ฟัง ฟัง</a><br />
<a href="เห็นอะไรในตัวฉัน.html">3.เห็นอะไรในตัวฉัน</a><br />
<a href="ความรู้มือหนึ่ง.html">4.ความรู้มือหนึ่ง</a><br />
<a href="/KM/Note taker/Web pages/เรื่องฉันเรื่องเธอ.html">5.เรื่องฉันเรื่องเธอ</a><br />
<a href="/KM/Note taker/Web pages/เรื่องนี้สอนให้รู้ว่า.html">6.เรื่องนี้สอนให้รู้ว่า</a><br />
<a href="/KM/Note taker/Web pages/karaoke.html">7.karaoke</a><br />
<a href="/KM/Note taker/Web pages/ดึงความรู้ปฏิบัติ.html">8.ดึงความรู้ปฏิบัติ</a><br />
<a href="/KM/Note taker/Web pages/เล่าเรื่องฉัน เขียนเรื่องเธอ.html">9.เล่าเรื่องฉัน เขียนเรื่องเธอ</a><br />
<a href="/KM/Note taker/Web pages/shopping idea .html">10.shopping idea </a><br />
<a href="/KM/Note taker/Web pages/กิจกรรม AAR (After Action Review).html">11.กิจกรรม AAR (After Action Review)</a></p> </td>
</tr>
<tr>
<td class="bodyText"><div align="justify">ตั้งแต่แรกเริ่มของการเดินทาง ทุกคนกระตือรือร้นมาที่เนเชอรัลบีช รีสอร์ท อ.แหลมสิงห์ ฝนตกปรอยๆตั้งแต่เช้า ที่พักชายทะเลจึงชุ่มช่ำ บรรยากาศหน้าห้องประชุม มีสมาชิกทยอยกันมาลงทะเบียน ด้วยบรรยากาศสบายๆ และอิ่มอร่อยกับอาหารเช้าที่เตรียมไว้ต้อนรับ ทุกคนยิ้มแย้ม พูดคุยทักทายกันอย่าง เป็นกันเอง สนุกสนาน <br />
หลังรับประทานอาหารเช้า แต่ละคนทยอยเข้าห้องประชุม ทุกคนดูตื่นเต้น กระตือรือร้น กับสิ่งที่กำลังจะได้พบในอีกไม่ช้านี้ <br />
เวลาประมาณ 8.35 น. พี่หมู (นภาพร) เกริ่นนำถึงเรื่องราวความเป็นมาของการประชุมครั้งนี้ เชิญ อาจารย์ ทนง กล่าวเปิดงานและและเชิญวิทยากร อย่างเป็นกันเอง คือ อาจารย์อุ (อุไรวรรณ เทิดบารมี) และอาจารย์หญิง (นภินทร ศิริไทย) และแนะนำ ส.ค.ส (สถาบันส่งเสริมการจัดการความรู้ เพื่อสังคม) อาจารย์ นั่งที่พื้นอย่างเป็นกันเอง ทำให้สมาชิกที่ประชุมที่นั่งอยู่บนเก้าอี้ ทยอยลงมานั่งพื้นพร้อมหมอนนิ่มๆ คนละใบ จนสุดท้าย ทุกคน ต่างนั่งอยู่ที่พื้นล้อมเป็นวง </div></td>
<td class="bodyText"> </td>
<td valign="top" class="bodyText"><a href="list.html">รายชื่อ Note taker และ ผู้เข้าร่วมฝึกอบรม</a><br />
<a href="certificate.html">รูปรับประกาศนียบัตร</a><br />
<a href="เรื่องเล่าที่เราภูมิใจ.html">เรื่องเล่าที่เราภูมิใจ</a><br />
วีดีโอ KM โรงพยาบาลตากใบ<br />
<table width="248" height="314" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="314"><embed src="/KM/Note taker/VDO/bantak.wmv" width="400" height="300"autostart="False" align="top"></embed></td>
</tr>
</table>
<br />
</td>
</tr>
<tr>
<td class="bodyText"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" height="160" align="left" valign="middle"><div align="left"><img width="161" height="139" src="../Photo/main_clip_image002_0000.jpg" /></div></td>
<td width="50%" height="160" align="right" valign="middle"><div align="right"><img width="161" height="139" src="../Photo/main_clip_image002.jpg" /></div></td>
</tr>
<tr>
<td height="160" align="center" valign="middle"><div align="left"><img width="161" height="139" src="../Photo/main_clip_image002_0001.jpg" /></div></td>
<td height="160" align="right" valign="middle"><div align="right"><img width="161" height="139" src="../Photo/main_clip_image002_0002.jpg" /></div></td>
</tr>
</table></td>
<td class="bodyText"> </td>
<td class="bodyText"> </td>
</tr>
<tr>
<td class="bodyText style1"><p><a href="http://www.amazingcounters.com"><span class="style2">จำนวนผู้เข้าชม <span class="style3">>></span></span> <p>
<?
$filename="number.txt";
$fp=fopen($filename,"r");
$get_number=fread($fp,filesize($filename));
fclose($fp);
if(!isset($_SESSION['NO_REFRESH'])
{
$get_number=$get_number+1;
$fp=fopen($filename,"w";
fwrite($fp,$get_number);
fclose($fp);
}
$counter=sprintf("%05d",$get_number);
for($i=0;$i<5;$i++){
echo"<img src='images/$gcounter[$i].gif'>";
}
?>
</p></td></h6>
<td class="bodyText"> </td>
<td class="bodyText"> </td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
|
 |
 |
 |
 |
Date :
2011-12-28 16:03:32 |
By :
wiki |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|