RE: [PHP] Counter
| From: | Merritt, Dave | Date: | Thu, 08 May 2003 14:57:32 +0000 |
| Subject: | RE: [PHP] Counter | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-146852@lists.php.net to get a copy of this message | ||
But if you know that the counter will increment by 7000 every 24 hours then
you don't need a cron job to count this. All you need is to know the time
the counter was first started from which can be embedded into the html, get
the current time, do some simple math, and then you'll know the value of the
counter at that moment in time. Meta refresh the page every so often and
your counter will increment. All of this can be done on the client side
using javascript, which I believe this was what Mark Douglas' original
answer to the question was.
-----Original Message-----
From: Chris Edwards [mailto:chris.edwards@obinet.com]
Sent: Thursday, May 08, 2003 10:08 AM
To: php-general@lists.php.net
Subject: Re: [PHP] Counter
Either way... javascript nor java can accomplish it....
he said the file is counting without user intervention all day...
the only way to create a counter that can do that is through a seperate
process that is not connected to the web.
cron can schedule a script to write to a file.
how you get that information out of the file is up to you. a frame and some
meta refresh is simple. can javascript read a file on the server? I think
not. Can java, why? it takes to long to load.
--
Chris Edwards
Web Application Developer
Outer Banks Internet, Inc.
252-441-6698
chris.edwards@obinet.com
http://www.OuterBanksInternet.com
----- Original Message -----
From: <bbonkosk@tampabay.rr.com>
To: "Chris Edwards" <chris.edwards@obinet.com>; <php-general@lists.php.net>
Sent: Thursday, May 08, 2003 5:57 AM
Subject: Re: [PHP] Counter
> Yes, this could be done in PHP to, but isn't that like using a screwdriver
to
> pound in a nail? This is clearly a case for client side programming. So
> either embedd a nice little java applet that gets a dynamically updated
file
> via sockets, or do some javascript algorithm that will appear to update
while
> the user is sitting at your site.
> -Brad
>
> > Hi
> >
> > setup a cron job to write to a file, the number you wish to see.
> >
> > then, use an <iframe>, http://www.w3schools.com/tags/tag_iframe.asp
> >
> > have the iframe page reload itself every second, reading the new number
from
> > the file.
> >
> > when a user loads the page, they will see the counter incrementing every
> > second, or whatever period you wish
> >
> >
> > --
> > Chris Edwards
> > Web Application Developer
> > Outer Banks Internet, Inc.
> > 252-441-6698
> > chris.edwards@obinet.com
> > http://www.OuterBanksInternet.com
> >
> > ----- Original Message -----
> > From: "Mark Douglas" <Mark.Douglas@Q9.com>
> > To: "'Shaun'" <shaun@mania.plus.com>;
<php-general@lists.php.net>
> > Sent: Thursday, May 08, 2003 9:36 AM
> > Subject: RE: [PHP] Counter
> >
> >
> > > If they want to see the counter incrementing while the user is sitting
on
> > > one page, you're going to have to do something in javascript or
another
> > > dynamic language. As is stated many times on this list, PHP is server
side
> > > only and will not make a webpage dynamic at the client side for you.
> > >
> > > -----Original Message-----
> > > From: Shaun [mailto:shaun@mania.plus.com]
> > > Sent: Thursday, May 08, 2003 9:31 AM
> > > To: php-general@lists.php.net
> > > Subject: Re: [PHP] Counter
> > >
> > >
> > > Thanks for your reply mark,
> > >
> > > but they want to see the counter actually incrementing whilst the user
is
> > on
> > > the site...
> > >
> > >
> > > "Mark Douglas" <Mark.Douglas@Q9.com> wrote in message
> > >
> >
news:05924A4A9DEDAD46A21EE3C8C64B090D02B6CDC6@cheetah.zoo.q9networks.com...
> > > > I'm not awake enough to provide example code, but something like
this
> > > should
> > > > work:
> > > >
> > > > - Set a base date
> > > > - Set a base counter value
> > > > - Get the current date, subtract base date, gives you number of days
> > since
> > > > start of counter
> > > > - multiple number of days since start of counter by 7000
> > > > - add this value to base counter value, giving you start of day
value
> > > > - divide 86400 by 7000 to give number of seconds that needs to pass
to
> > > > increment value
> > > > - count number of seconds that has passed in the day, divide by
number o
> > f
> > > > seconds to increment, giving todays current addition to counter
> > > > - add current addition to start of day value
> > > >
> > > > Voila, you have a piece of code that you can put in a header/footer
on
> > > every
> > > > page and will be different every time a user loads a page. This is
> > > asssuming
> > > > you're just going on the 7000/day value, and not actually caring
about
> > the
> > > > real number of units sold.
> > > >
> > > > I hope that didn't confuse too much.
> > > >
> > > > Mark
> > > >
> > > > -----Original Message-----
> > > > From: Shaun [mailto:shaun@mania.plus.com]
> > > > Sent: Thursday, May 08, 2003 9:13 AM
> > > > To: php-general@lists.php.net
> > > > Subject: [PHP] Counter
> > > >
> > > >
> > > > Hi,
> > > >
> > > > I have a client who wants a counter on their site showing a number
which
> > > > rises by 7000 a day and visibly clocks up whilst a user is on the
site.
> > > This
> > > > is meant to show the number of products they sell a a day. I'm just
not
> > > sure
> > > > how this would work though, would i have to store the ammount in a
> > > database,
> > > > how would it increment whilst no one is one the site.
> > > >
> > > > Thanks for your help
> > > >
> > > >
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php