Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 11th Feb 2011, 03:21 PM   #1
Active Warrior
 
Join Date: 2011
Posts: 33
Thanks: 2
Thanked 3 Times in 2 Posts
Default
PHP Countdown Items Remaining Code??
Share on: 
fb share twitter share gplus share more share

I'm looking for a script that will display a number and drop it down 1 by 1 until its down to 1, for the purpose of simulating the number of available items remaining. It would be more realistic if the number didn't countdown at a consistent interval, but was a bit random.

I've done a lot of searching, but all I could find was countdowns to dates. Does anyone have a script for this that they would be willing to share?

Thanks.
magicink is offline  
Unread 11th Feb 2011, 04:29 PM   #2
HyperActive Warrior
War Room Member
 
michael_gourlay's Avatar
 
Join Date: 2010
Location: New Jersey, USA
Posts: 102
Thanks: 4
Thanked 18 Times in 16 Posts
Default
Re: PHP Countdown Items Remaining Code??
Share on: 
fb share twitter share gplus share more share

Do you want it to count down while the person is looking at the page (ie they see it going down)? If so, javascript may be a better option than PHP.
michael_gourlay is offline  
Unread 11th Feb 2011, 04:43 PM   #3
Warrior Member
War Room Member
 
Join Date: 2010
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default
Re: PHP Countdown Items Remaining Code??
Share on: 
fb share twitter share gplus share more share

Countdown on page refresh? Or countdown without page reload?
BizLeadMachine is offline  
Unread 12th Feb 2011, 10:40 AM   #4
Active Warrior
 
Join Date: 2011
Posts: 33
Thanks: 2
Thanked 3 Times in 2 Posts
Default
Re: PHP Countdown Items Remaining Code??
Share on: 
fb share twitter share gplus share more share

Without page reload.
magicink is offline  
Unread 12th Feb 2011, 12:15 PM   #5
Peaceful Warrior
War Room Member
 
theIMgeek's Avatar
 
Join Date: 2009
Location: Calgary
Posts: 277
Thanks: 16
Thanked 106 Times in 63 Posts
Default
Re: PHP Countdown Items Remaining Code??
Share on: 
fb share twitter share gplus share more share

What I would do...

Run a program that randomly selects a number from 1 to 5 every x seconds. If it picked 1, then drop the quantity, otherwise, keep it the same.

That way it would change in a truly random way.

Now, if you do this in straight-up javascript (which is required to see the changes in "real-time") there is the problem that your sham of an inventory would be revealed if a person peeks at the page source code. (all the javascript would be exposed)

If you want to be more discrete you would need to run the random function via AJAX so the processing is done "secretly" with PHP or something.

-Ryan

FREE WSO: Protect and Automatically Deliver Your Digital Products

Ask the Internet Marketing Geek
<-- Happy to help with technical challenges
MiniSiteMaker.org <-- Free software to make your mini-sites fast and easy
theIMgeek is offline  
Unread 12th Feb 2011, 07:30 PM   #6
Active Warrior
 
Join Date: 2011
Posts: 33
Thanks: 2
Thanked 3 Times in 2 Posts
Default
Re: PHP Countdown Items Remaining Code??
Share on: 
fb share twitter share gplus share more share

It's funny cause I was thinking the same thing. Guess its a pretty basic script.

I'm not too worried about people peeking. If anything I'd be more worried about someone hitting refresh and seeing it jump right back to the initial inventory count, but its PPV so whatever.
magicink is offline  
Unread 12th Feb 2011, 09:56 PM   #7
Engineer
War Room Member
 
Damien Roche's Avatar
 
Join Date: 2007
Location: In The Machine
Posts: 627
Thanks: 151
Thanked 103 Times in 72 Posts
Default
Re: PHP Countdown Items Remaining Code??
Share on: 
fb share twitter share gplus share more share

You could use sessions to maintain consistency between page refreshes. It is very simple stuff - you could also use AJAX which would completely avoid people from peeking. However, I do think that's a little paranoid

>> 20 Years Full-Stack Engineer (frontend, backend, devops), Game Dev (UE5), AI Systems Dev <<
Available for Fixed Fee Projects and Hourly Contract Work
Damien Roche is offline  
Closed Thread


Bookmarks

Tags
code, countdown, items, php, remaining


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 10:34 AM.