Hey I'm trying to create a graph and then I want to let people click yes or no as to whether something works, for example a coupon. I have the yes/no functionality and when someone clicks yes it'll insert into the database: mysql_query("INSERT INTO `success` (success_yn, success_couponid, success_ip) VALUES ('" . $_POST['success_yn'] . "', '" . $_POST['success_couponid'] . "', '" . $_POST['success_ip'] . "')"); Code (markup): Now, for the graph I want to show data for the last 30 days and then split it up by day, so I want a line for each day. Example: Then, I want to calculate the percentage success rate each day and then put it into an array. $array = array('43', '21'); Where 43 and 21 and percentages for day and day 2. Effectively I'll end up with a graph that shows the success rate daily for the last 30 days. What I don't know how to do is select the data for the last 30 days and then split it up day by day, I don't have anything recording the date the coupon was rated and obviously I need to do that, but I don't know what format I should have.. Sorry if I confused you, but anyone got any ideas?
Guessing I confused everyone, what I'm trying to do is limit my query to select the ratings that have been submitted within the last 30 days, and then I want to split them up into daily ratings, so I have the ratings for every day for the last 30 days.
Add a timestamp field to your database entries, for example from the php time() function. To select data from the last 30 days then use for example : "select .. from ... where timestamp > '".time()-30*24*3600."'";