close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

filtering results from a recordset

Thread began 8/19/2013 2:43 pm by Christopher West | Last modified 8/20/2013 11:09 am by Christopher West | 725 views | 7 replies

Christopher WestCommunity Expert

Hey Jason, with some direction from Ray, I have modified what I was doing...I just wanted to make sure that the calculation is correct.

so therefore for finding out the most popular product category...would this calculation work (its hard to test without having to manually go through all the orders in the database and work out the math lol)

$result = mysql_query('SELECT CategoryName FROM orderdetails INNER JOIN products ON orderdetails.DetailProductID = products.ProductID INNER JOIN productcategories ON products.ProductCategoryID = productcategories.CategoryID GROUP BY productcategories.CategoryName ORDER BY Count(*) DESC LIMIT 1') or die(mysql_error());
$PopularCategory = mysql_fetch_assoc($result);

Also for using the above and modifying to find results using dates...how would I calculate say for example - the revenue for the previous month then also for the current month....reason why i ask is the example you gave yesterday regarding to calculate the sum by month is the result gave a very unusual value since I was able to calculate the result manually it doesnt match the result from the recordset query.

Chris

I need to double check result.. but I think I worked out the date in terms of popular month for transactions:

php:
<?php

$result 
mysql_query('SELECT OrderDate FROM orders GROUP BY DATE_FORMAT(OrderDate, "%m") ORDER BY Count(*) DESC  LIMIT 1') or die(mysql_error());
$PopularMonth mysql_fetch_assoc($result);
?>



Then to display this result:

php:
<?php echo date('M',strtotime($PopularMonth['OrderDate'])); ?>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...