Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-25-2012, 02:03 AM   PM User | #1
sonny
Regular Coder

 
sonny's Avatar
 
Join Date: Apr 2008
Location: United States
Posts: 567
Thanks: 88
Thanked 0 Times in 0 Posts
sonny can only hope to improve
php pie chart from DB

Hi, I am trying to create a pie chart for diff browser versions
Like MSIE 9.0. FireFox etc

I have the chart code working, just looking for the best way
to get data from MySQL

example, this works fine
<img src="PieChart.php?data=1*3*5*10&label=MSIE 9.0*MSIE 8.0*MSIE 7.0*MSIE 6.0 />

what would be the best way to count and label results for chart?

Update works fine now
PHP Code:

$result1 
mysql_query("SELECT * FROM mytable WHERE ua LIKE '%MSIE 9.0%'"); 
$E9 mysql_num_rows($result1);

$result2 mysql_query("SELECT * FROM mytable WHERE ua LIKE '%MSIE 6.0%'"); 
$E6 mysql_num_rows($result2); // etc.....

$data"$E9*$E6";
$label "MSIE 9.0*MSIE 6.0"
Thanks
Sonny

Last edited by sonny; 11-25-2012 at 07:19 AM..
sonny is offline   Reply With Quote
Old 12-08-2012, 08:19 AM   PM User | #2
koolphpnet
Banned

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
koolphpnet is an unknown quantity at this point
It is better that you put all the browser type into an array first and loop through array to pull out result:
PHP Code:
$arr=array("Firefox","MSIE");
$data "";
$label "";
for(var 
$i=0;$<count($arr);$i++)
{
   
$result mysql_query("SELECT * FROM mytable WHERE ua LIKE '%".$arr[$i]."'");  
  
$num mysql_num_rows($result); 
  
$data =  $num.(($=0)?"":"*");
  
$label =  $arr[$i].(($=0)?"":"*");

By the way here is an great interactive chart for PHP:

http://demo.koolphp.net/Examples/Koo...hart/index.php
koolphpnet is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:02 AM.


Advertisement
Log in to turn off these ads.