View previous topic :: View next topic |
Author |
Message |
PsychoticLucky7 -
Joined: 18 Aug 2004 Posts: 15
|
Posted: Sat Nov 20, 2004 12:44 am Post subject: Problems with hit counter, Please Help |
|
|
I am hosting my own site and my own hit counter, the counter works but I cannot get it to add leading zeros to the displayed mumber. Lets say that I have had 3 people on my site, and instead of the counter displaying 3, I would like it to display 0003. I've tried to put the zeros in the txt file but the php script delets them and displays 3. Can anyone help?
Code: |
<html>
<body bgcolor="black">
<?
$dj = "hits.txt";
$fp = fopen($dj,"rb");
$kj = trim(fread($fp,filesize($dj)));
if ($kj != "") $kj++;
else $kj = 1;
@fclose($fp);
$fp = fopen($dj,"w");
@fputs($fp,$kj);
for($x=0;$x<strlen($kj);$x++) {
$img2 = substr($kj,$x,1);
$count .= "<img src='images/$img2.gif'>";
}
@fclose($fp);
echo "$count";
?>
</body>
</html>
|
_________________ InSaNiTy Is A gIfT! |
|
Back to top |
|
 |
k1ll3rdr4g0n -
Joined: 04 Jul 2004 Posts: 609
|
Posted: Sat Nov 20, 2004 2:36 am Post subject: |
|
|
Code: | <html>
<body bgcolor="black">
<?
$dj = "hits.txt";
$fp = fopen($dj,"rb");
$kj = trim(fread($fp,filesize($dj)));
if ($kj != "") $kj++;
else $kj = 1;
@fclose($fp);
$fp = fopen($dj,"w");
@fputs($fp,$kj);
for($x=0;$x<strlen($kj);$x++) {
$img2 = substr($kj,$x,1);
$count = "<img src='images/$img2.gif'>";
}
@fclose($fp);
echo "000" . $count;
?>
</body>
</html>
|
Try that..... _________________
 |
|
Back to top |
|
 |
PsychoticLucky7 -
Joined: 18 Aug 2004 Posts: 15
|
Posted: Sat Nov 20, 2004 2:42 am Post subject: |
|
|
k1ll3rdr4g0n wrote: |
Try that..... |
Thanks for the help, but all it did was push the number over a couple of spaces and displayed empty space in the place of the zeros...
-PsychoticLucky7 _________________ InSaNiTy Is A gIfT! |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Sat Nov 20, 2004 4:20 am Post subject: |
|
|
Thats because their is a space between the 000 , try this. LateR!
Edit: Try Aprelium's code instead , I got nothing...
Last edited by TRUSTAbyss on Sat Nov 20, 2004 11:24 am; edited 2 times in total |
|
Back to top |
|
 |
admin Site Admin
Joined: 03 Mar 2002 Posts: 1332
|
Posted: Sat Nov 20, 2004 10:04 am Post subject: |
|
|
Try this:
Code: | <html>
<body bgcolor="black">
<?
$dj = "hits.txt";
$fp = fopen($dj,"rb");
$kj = trim(fread($fp,filesize($dj)));
if ($kj != "") $kj++;
else $kj = 1;
@fclose($fp);
$fp = fopen($dj,"w");
@fputs($fp,$kj);
$kj = sprintf("%04d", intval($kj));
for($x=0;$x<strlen($kj);$x++) {
$img2 = substr($kj,$x,1);
$count = "<img src='images/$img2.gif'>";
}
@fclose($fp);
echo $count;
?>
</body>
</html>
|
|
|
Back to top |
|
 |
PsychoticLucky7 -
Joined: 18 Aug 2004 Posts: 15
|
Posted: Sat Nov 20, 2004 5:50 pm Post subject: |
|
|
thanks for all of your help,I couldn't appreciate it more, but that code produced the same result as my original.
I think I'll just give it up,
Thanks Guys...
-PsychoticLucky7 _________________ InSaNiTy Is A gIfT! |
|
Back to top |
|
 |
|