TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-05-2008, 12:08 PM   #1 (permalink)
The Contributor
 
Join Date: Dec 2007
Posts: 27
Thanks: 0
crazyryan is on a distinguished road
Default PHP GD Graphs

Hey

I'm calculating the success of whether coupons work or not and would also like to show what times the coupon worked.

Like on Amazon.com Coupon Codes - all coupons, discounts and promo codes for amazon.com

If you check out the coupon they have an image like this:


I imagine that is showing at what times since the coupon was added it was working, so at first it was working but then it started to get reported as not working..

Would it be hard to create something like this and how would I go about doing it?

Right now in my database I am storing what couponid the user rates, whether it works (yes/no) and what rating id theres is, I assume I'd have to add the date when it was rated as well
crazyryan is offline  
Reply With Quote
Old 04-05-2008, 12:48 PM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Take a look at Sparkline PHP Graphing Library. I'm almost certain that is what is being used and it's a nice simple library to learn.

Would it be hard to make these graphs? Not at all.
Do you need to store the dates of each rating? Yes!
Salathe is offline  
Reply With Quote
Old 04-05-2008, 01:01 PM   #3 (permalink)
The Contributor
 
Join Date: Dec 2007
Posts: 27
Thanks: 0
crazyryan is on a distinguished road
Default

Ok cool. I downloaded sparkline and looked at some of the examples and samples/deficit.php seems to be what retailmenot are using, or atleast thats what the procuded graph looks like.

In deficit.php they have this:
PHP Code:
$data = array(1983 => 207.802,
              
1984 => -185.367,
              
1985 => -212.308,
              
1986 => -221.215,
              
1987 => -149.728,
              
1988 => -155.152,
              
1989 => -152.456,
              
1990 => -221.195,
              
1991 => -269.328,
              
1992 => -290.376,
              
1993 => -255.087,
              
1994 => -203.250,
              
1995 => -163.972,
              
1996 => -107.473,
              
1997 =>  -21.958,
              
1998 =>   69.213,
              
1999 =>  125.563,
              
2000 =>  236.445,
              
2001 =>  127.299,
              
2002 => -157.802,
              
2003 => -304.159); 
I edited some of the values and thats whats being shown in the graph. How would I put my data into that, I guess I need to work out the percentage in a week or every 2 weeks or something, and then put it into that array?
crazyryan is offline  
Reply With Quote
Old 04-05-2008, 11:11 PM   #4 (permalink)
The Contributor
 
Join Date: Dec 2007
Posts: 27
Thanks: 0
crazyryan is on a distinguished road
Default

Anyone have any ideas? I want to put the percentages for the last 30 days into the graph, but I dunno how to select the percentage for each day for the last 30 days, my structure is like so:
success_id, success_couponid, success_yn, success_ip, success_time
1, 21, yes, 127.0.0.1, time();
crazyryan is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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


All times are GMT. The time now is 05:20 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design