TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   PHP GD Graphs (http://www.talkphp.com/general/2586-php-gd-graphs.html)

crazyryan 04-05-2008 12:08 PM

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

Salathe 04-05-2008 12:48 PM

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!

crazyryan 04-05-2008 01:01 PM

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 04-05-2008 11:11 PM

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();


All times are GMT. The time now is 01:54 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0