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 01-31-2013, 03:14 PM   PM User | #1
Vernk
Regular Coder

 
Join Date: Oct 2011
Posts: 113
Thanks: 9
Thanked 1 Time in 1 Post
Vernk is an unknown quantity at this point
Making a Graph with my current data

Hello,

I currently want to make a graph with my data in my database. My template already comes with the graph. This is the data I have :



This is the Graph.
I want to have every hour on the bottom , and the amount of rows in that hour on the side.



Here is the graph code:
PHP Code:
<table id="graph-data" class="graph">
                                <
caption>2009 Employee Sales by Department</caption>
                                <
thead>
                                    <
tr>
                                        <
td></td>
                                        <
th scope="col">food</th>
                                        <
th scope="col">auto</th>
                                        <
th scope="col">household</th>
                                        <
th scope="col">furniture</th>
                                        <
th scope="col">kitchen</th>
                                        <
th scope="col">bath</th>
                                    </
tr>
                                </
thead>
                                <
tbody>
                                    <
tr>
                                        <
th scope="row">Mary</th>
                                        <
td>190</td>
                                        <
td>160</td>
                                        <
td>40</td>
                                        <
td>120</td>
                                        <
td>30</td>
                                        <
td>70</td>
                                    </
tr>
                                    <
tr>
                                        <
th scope="row">Tom</th>
                                        <
td>3</td>
                                        <
td>40</td>
                                        <
td>30</td>
                                        <
td>45</td>
                                        <
td>35</td>
                                        <
td>49</td>
                                    </
tr>
                                    <
tr>
                                        <
th scope="row">Brad</th>
                                        <
td>10</td>
                                        <
td>180</td>
                                        <
td>10</td>
                                        <
td>85</td>
                                        <
td>25</td>
                                        <
td>79</td>
                                    </
tr>
                                    <
tr>
                                        <
th scope="row">Kate</th>
                                        <
td>40</td>
                                        <
td>80</td>
                                        <
td>90</td>
                                        <
td>25</td>
                                        <
td>15</td>
                                        <
td>119</td>
                                    </
tr>        
                                </
tbody>
                            </
table

Help is much appreciated... Thanks!
Vernk is offline   Reply With Quote
Old 02-01-2013, 12:10 AM   PM User | #2
Vernk
Regular Coder

 
Join Date: Oct 2011
Posts: 113
Thanks: 9
Thanked 1 Time in 1 Post
Vernk is an unknown quantity at this point
Hello,

Is anyone able to help
?

Vernk is offline   Reply With Quote
Old 02-01-2013, 12:13 AM   PM User | #3
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Does it use HTML to generate that graph? The image appears to be an image of a graph but I don't see any GD manipulations here.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 02-01-2013, 12:27 AM   PM User | #4
Vernk
Regular Coder

 
Join Date: Oct 2011
Posts: 113
Thanks: 9
Thanked 1 Time in 1 Post
Vernk is an unknown quantity at this point
Uhh yea I just want to know how to make it dynamic. The graph uses a ton of other stuff I just need to know how to make the graph with the DB data I have
Vernk is offline   Reply With Quote
Old 02-01-2013, 03:06 PM   PM User | #5
Vernk
Regular Coder

 
Join Date: Oct 2011
Posts: 113
Thanks: 9
Thanked 1 Time in 1 Post
Vernk is an unknown quantity at this point
Please
Vernk is offline   Reply With Quote
Old 02-01-2013, 04:28 PM   PM User | #6
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Well not really. If you just need to build an HTML table simply query out what you need. Hour by hour would require you to aggregate it in some fashion, but since you provide no information to the meaning of any of this data, its hard to say what to do with it. Sounds like you simply need to pull the count and the HOUR of the timestamp, but it would only hold value if you group it by something (the HOUR perhaps?), and you give it a date range to look in.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 02-01-2013, 06:35 PM   PM User | #7
DrDOS
Senior Coder

 
Join Date: Sep 2010
Posts: 1,146
Thanks: 10
Thanked 148 Times in 148 Posts
DrDOS is infamous around these parts
PhP works very well with ,svg files. You can use it to make all kinds of graphs and other presentations dynamically. You can use the PhP download dialog to download the .svg file or something like ImageMagick to convert to a .png or other more common graphic format as part of the download dialog.
DrDOS 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 09:59 AM.


Advertisement
Log in to turn off these ads.