cloudy

Author Topic: MySQL -> JpGraph Interface  (Read 28681 times)

0 Members and 1 Guest are viewing this topic.

Offline kv-swe

  • Posts: 282
  • Sweden
    • Vädret i Hasslösa
MySQL -> JpGraph Interface
« on: November 17, 2007, 10:47:32 PM »
Hi
I have created a interface script to view JpGraph´s from MySQL.
It can be viewed here: http://www.hasslosa.se/weather/wd/wx6en.php
(Compare intervals does not work so well, i think it's because the db misses some values.)
I have attached a zip-file with the code if someone would like to use it, or just have some fun looking at my code.  :roll:

 :) Krister
« Last Edit: February 22, 2010, 06:17:28 PM by kv-swe »

Offline jwwd

  • Posts: 3,544
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: MySQL -> JpGraph Interface
« Reply #1 on: November 18, 2007, 06:13:29 AM »
Hi Krister

What a great script. Now I have something to play with today and maybe translate to Danish.

Best regards,

Henrik

Offline Mario

  • Posts: 6
Re: MySQL -> JpGraph Interface
« Reply #2 on: November 18, 2007, 01:58:53 PM »
thanks man!!!
Your site is inspirational :headbang:

Offline kv-swe

  • Posts: 282
  • Sweden
    • Vädret i Hasslösa
Re: MySQL -> JpGraph Interface
« Reply #3 on: November 18, 2007, 04:46:34 PM »
Hi Henrik and Mario
I'm glad you like it  :D
If you downloaded the first version you should delete the database connection info in common_en.php
I forgot to erase it  :oops:
The database connection info should be entered in get_data.php, and it might mess things up if it remains in common_en.php

 :) Krister

Offline jwwd

  • Posts: 3,544
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: MySQL -> JpGraph Interface
« Reply #4 on: November 18, 2007, 05:36:53 PM »
Hi Krister

I have been playing with your scripts - but cant get it to work.

I dont know whats wrong. I have downloaded your latest release.

Link: http://www.buskelundtoften.dk/vejret/webpages/multiwx_en.php

What can be the problem?

Best regards,

Henrik

Offline kv-swe

  • Posts: 282
  • Sweden
    • Vädret i Hasslösa
Re: MySQL -> JpGraph Interface
« Reply #5 on: November 18, 2007, 06:11:15 PM »
Hi Henrik
Is the path to Jpgraph correct?
The default path is Jpgraph src folder is in the same folder as multiwx and webpages folder
You can change this in multigraph.php

 :)  Krister




Offline jwwd

  • Posts: 3,544
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: MySQL -> JpGraph Interface
« Reply #6 on: November 18, 2007, 06:15:48 PM »
Hi Krister

Thanks for your reply.

Yes my "src" folder is in the same folder as multiwx and webpages folder.

I have dobble checked the connection string to mysql database and everything seems correct.

Best regards,

Henrik

Offline kv-swe

  • Posts: 282
  • Sweden
    • Vädret i Hasslösa
Re: MySQL -> JpGraph Interface
« Reply #7 on: November 18, 2007, 06:35:04 PM »
Hi again
change
Code: [Select]
include ($com_lang); in get_data.php to 
Code: [Select]
include ('common_en.php');and see if it works

 :) Krister
« Last Edit: November 18, 2007, 07:07:56 PM by kv-swe »

Offline jwwd

  • Posts: 3,544
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: MySQL -> JpGraph Interface
« Reply #8 on: November 18, 2007, 07:54:57 PM »
Hi Krister

Sorry - still no luck.

Best regards,

Henrik

Ps. my webhotel is running on a Windows 2003 server - could that be the problem?

Offline kv-swe

  • Posts: 282
  • Sweden
    • Vädret i Hasslösa
Re: MySQL -> JpGraph Interface
« Reply #9 on: November 18, 2007, 08:32:23 PM »
Hi again
If you go directly to http://www.buskelundtoften.dk/vejret/multiwx/multigraph.php
you will see this: getmysql error (If it works you will see a graph).
Before it complained that it could not find the included file, so that is fixed, i don't know why it did not work.
If you are using the original WDMYSQL table you need to change the mysql_query because it uses datetime and that field does not exist
in the original table. == getmysql error
You also have to change  the arrays $db_field , $db_units and $db_fieldname so it matches your database

 :) Krister

Offline jwwd

  • Posts: 3,544
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: MySQL -> JpGraph Interface
« Reply #10 on: November 18, 2007, 08:38:49 PM »
Hi again

Yes i use the origina wdmysql database/table

Im not sure what to change in the script.

Best regards,

Henrik

Offline kv-swe

  • Posts: 282
  • Sweden
    • Vädret i Hasslösa
Re: MySQL -> JpGraph Interface
« Reply #11 on: November 18, 2007, 09:18:28 PM »
Hi again
In common_en.php  the array $db_field  should contain the field names of the database like this:
Code: [Select]
$db_field = array("" => "", 1 => "station_id", 2 => "date", 3 => "time", 4 => "average_windspeed"..............
and in
Code: [Select]
$db_units = array("" => "", 1 => "", 2 => "Date", 3 => "Time", 4 => "m/s"........
and in $db_fieldname the fields you want in the select droplist. The key number is the same as in $db_field , the text is just for the droplist so it can be translated.

The query:
 
Code: [Select]
$sql = mysql_query("SELECT UNIX_TIMESTAMP(DATETIME) AS DATETIME, DATETIME, $que1 AND humidity IS NOT NULL ORDER BY DATETIME ASC") or die("getmysql error");does not work because your database does not have DATETIME, you have to use DATE and TIME in the query , i'm not sure how to do that  #-o

 :) Krister

Offline jwwd

  • Posts: 3,544
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: MySQL -> JpGraph Interface
« Reply #12 on: November 18, 2007, 09:29:51 PM »
Hi Krister

Thank you very much for your reply.

I hope somebody can modify your excellent script to work with the original wdmysql database.

Best regards,

Henrik

Offline kv-swe

  • Posts: 282
  • Sweden
    • Vädret i Hasslösa
Re: MySQL -> JpGraph Interface
« Reply #13 on: November 19, 2007, 05:00:11 PM »
Hi again
I have modified the script so it should work with the WDMySQL-table
(It works on my testtable on localhost with 2 hours of data)  :roll:
I have not added all fields for the select droplist, but it is easy to add more in common_en.php and rename/translate them.
I have attached a zip-file with the new code
 :) Krister
« Last Edit: January 11, 2008, 03:43:15 PM by kv-swe »

Offline jwwd

  • Posts: 3,544
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: MySQL -> JpGraph Interface
« Reply #14 on: November 19, 2007, 06:47:46 PM »
Hi Krister

Thanks for all your work.

Unfortunately I cant get it to work. I have the mysql settings in the get_data.php file.

Anything else to do?

www.buskelundtoften.dk/vejret/webpages/multiwx_en.php

Best regards,

Henrik