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

rating

charts.js help needed

Thread began 3/04/2016 8:07 am by Kumel | Last modified 3/04/2016 2:14 pm by Ray Borduin | 684 views | 10 replies |

Kumel

charts.js help needed

I m creating chart using http://www.chartjs.org This is as per my client requirements.

So in chart i gotta display no of products in each category.
Products & Categories are created from dataassist So i believe the DB structure is well known to all here.

So i want to know what will be the fastest & easiest way to display this.

Currently i created RS of each ProductCategory ex:
$query_A = "SELECT CatID FROM Products WHERE CatID = 1";
$query_B = "SELECT CatID FROM Products WHERE CatID = 2";
& so on.. then using value: <?php echo $totalRows_A ?>,

So this is making me create tooo many RS.

So if clients add new category i don't want to manually add rs to each pages.

So how can this be done auto?
There must be a simple & easy way. i m not able to fix it. Please advise.

Sign in to reply to this post

Ray BorduinWebAssist

SELECT CatID, Count(*) AS CatCount FROM Products GROUP BY CatID

Sign in to reply to this post

Kumel

So how to display total number of 1st record in category?
Lets say i want to display total numbers of product of category named "xyz". Lets say there are 25 products under that category. so want to display total no as 25.

Then lets say category named "abc" has 10 products. then i want to display 10.

So how to do this?

Sign in to reply to this post

Ray BorduinWebAssist

Loop through the recordset. There will be one row for each category. You can add an INNER JOIN to get the category name.

Sign in to reply to this post

Kumel

Products Table:

ID, Name, CatID


Categories:

ID, CatName


Products List:

1 , Iphone, 1
2, Samung s3, 1
3, Mac book , 2
4, Apple Headphone, 3



Categories:

1, Mobiles
2, Laptop
3, Headsets




So as above Records lets say i want to display:
No of Mobiles:
No of laptops:
No of Headsets:

Sign in to reply to this post

Ray BorduinWebAssist

SELECT CatName, Count(*) AS CatCount FROM Products INNER JOIN Categories ON Categories.ID = Products.CatID GROUP BY CatID

Then add a repeated region on the page and you can display the CatName and CatCount for each of the categories.

Sign in to reply to this post

Kumel

Awesome it does display Total Nos. How about display CatName as well?

just like:

Mobiles 2
Laptops 1
Headphone 1

Sign in to reply to this post

Ray BorduinWebAssist

The SQL already has the CatName in it... you can add whatever other columns you want.

Sign in to reply to this post

Kumel

Oh ok. How about if i want to exclude a data of category ie Mobiles..

Just like:
Laptops 1
Heaphone 1..

Like WHERE NOT ( '1')

Sign in to reply to this post

Ray BorduinWebAssist

Just add a WHERE clause before the GROUP BY like:

SELECT CatName, Count(*) AS CatCount FROM Products INNER JOIN Categories ON Categories.ID = Products.CatID WHERE Categories.ID <> 1 GROUP BY CatID

Sign in to reply to this post
loading

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...