![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,116
|
![]() So one of our sales channels gives us a .csv file at the end of every pay period with full sales stats in it, I can get it into an SQL database through myAdmin no problems, im working on coding a .php script to upload it directly, that isnt the issue.
Once the data is upload to the SQL database, how would i go about manipulating it to show the data in a more collated form, grouping together all titles, sales numbers, etc? For example, how would I go about coding a page (or section) that shows the total sales over the past year of Title1, Title2, Title3, etc grouped together? I can display the data of each row individually based on Title name, but some of the titles have 100-200 sales a month, thats a lot of scrolling to collect individual sales figures per title, I know there is a way to do it automagically, what should I be looking for online tutorial wise to achieve this? Thanks ![]()
__________________
NOTHING TO SEE HERE |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,053
|
Select title, sum(amount) to total_amount from tablename where invoice_date>=date_sub(curdate(), INTERVAL 1 YEAR) group by title
.
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 | |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,116
|
Quote:
![]() Now another question I have is, can I include that in a drop down menu to select a range of different options? For example, Title, Author, Sales Channel, etc, etc? I'm trying to minimize the amount of navigation required so just being able to throw together 1 page and have a drop down to change reports would be a perfect solution, if its not too involved lol
__________________
NOTHING TO SEE HERE |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,053
|
Quote:
.
__________________
All cookies cleared! |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,116
|
How would I go about transfering the dropdown option to the SQL query? JavaScript or?
__________________
NOTHING TO SEE HERE |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,116
|
Sorry, one more question about the total_amount... If a row has -1 would that be taken into account when the code collates the total or, will that just do individual columns?
(does that make sense?)
__________________
NOTHING TO SEE HERE |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 | ||
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,053
|
Quote:
When the form is submitted you capture the POST or GET corresponding to the "select" element. Then you use that value in your query. Quote:
That does not make sense to me, not sure what you are asking. .
__________________
All cookies cleared! |
||
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,116
|
I have a column with sales, for example 5, and another column that has refunds, -2 would the total_amount be 3 when displayed?
__________________
NOTHING TO SEE HERE |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 | |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,116
|
Quote:
In essence, sales vs. chargebacks.
__________________
NOTHING TO SEE HERE |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 | |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,053
|
Quote:
You would have to do something like select sum(sales + refunds) to total_amount But don't take my word for it. Run some test queies, play with the sql some so you can see the results. .
__________________
All cookies cleared! |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 | |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,116
|
Quote:
![]()
__________________
NOTHING TO SEE HERE |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,053
|
<html>
<head> <base href="https://gfy.com/" /><!--[if IE]></base><![endif]--> <base href="https://gfy.com/" /><!--[if IE]></base><![endif]--> </head> <body> <?php //establish oyur database connection here // assuming your connection is called $db // using PDO because it is best to use $validtypes=array('title','author','channel'); if(isset($_POST['reptype'])) { $rtype=stripslashes($_POST['reptype']); if(in_array($rtype,$validtypes)) { $sql_str="select ?, sum(invoice_amount) as total_amount from tablename where date_sub(curdate(), INTERVAL 1 YEAR) group by ?"; $result=$db->prepare($sql_str)); $result->execute($rtpe, $rtype); while($row=$result->fetch(PDO::FETCH_ASSOC)) { // echo data here } } else { // put some error code here } echo "<br><a href=thispage.php>Run another report</a></br>"; } else { ?> <form name="reportform" method=POST" action="thispage.php"> Select report type: <select name="reptype" onChange="this.form.submit();"> <option "title">By Title</option> <option "author">By Author</option> <option "channel">By Channel</option> </select> </form> <?php } ?> </body> </html>
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 |
Registered User
Industry Role:
Join Date: Jun 2022
Posts: 37
|
@publisherbucks Forget doing it the hard way, set up metabase (very quick and simple to get up and running) or redash (both free) and use their query builder and choose the way you want the data to display in minutes. It will pull the data directly from the database. You can choose the type of charts to display. Then build a dashboard to group your charts for easier and quicker viewing.
|
![]() |
![]() ![]() ![]() ![]() ![]() |