Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] przerobienie pobierania danych z mysql
mazyl
post
Post #1





Grupa: Zarejestrowani
Postów: 139
Pomógł: 2
Dołączył: 2.12.2011

Ostrzeżenie: (0%)
-----


Witam!
Mam oto taki problem.

Chce utowrzyc wykres przy pomocy skryptu, skrypt pobiera dane do wykresu dzięki:
  1. $LabChartsLine->setData(array(7,15,50,21,15,29,15,21,16,-23,4,18,17,21,17,19,16,25,62,15));

gdzie liczby oznaczaja odpowiednie miejsce w wykresie.
Pisałem już w przedszkolu ale nie otrzymałem odpowiedzi.

jak przerobić to tak, aby pobierane były liczby z bazy danych.

dostałem coś takiego:
  1. <?php
  2. $zapytanie = mysql_query("select * from wykres where serwer = ".$serw['id']." order by data DESC");
  3. $array = array();
  4. while ($data = mysql_fetch_assoc($zapytanie)) {
  5. $array[]=$data['gracze'];
  6. }
  7. $LabChartsLine->setData($array);
  8. ?>


Lecz to niestety nie działa.
ktoś ma może jakiś pomysł ? walcze z tym już pare dni i 0 efektów (IMG:style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
mazyl
post
Post #2





Grupa: Zarejestrowani
Postów: 139
Pomógł: 2
Dołączył: 2.12.2011

Ostrzeżenie: (0%)
-----


  1. <?php
  2. /*
  3.  * LabCharts version 1.2
  4.  * <a href="http://www.code-laboratory.com/" target="_blank">http://www.code-laboratory.com/</a>
  5.  *
  6.  * Copyright (c) 2009 <a href="http://code-laboratory.com" target="_blank">http://code-laboratory.com</a>
  7.  * Dual licensed under the MIT and GPL licenses.
  8.  *
  9.  * 2009-12-04 19:00
  10.  * 2010-01-30 13:25 edited to v 1.1
  11.  * 2010-05-22 22:47 edited to v 1.2
  12.  */
  13.  
  14. include_once(dirname(__FILE__) . '/LabCharts.php');
  15.  
  16. class LabChartsLine extends LabCharts {
  17.  
  18. private $min;
  19. private $max;
  20.  
  21. public function __construct () {
  22. $this->_type = 'lc';
  23. $this->_colors = 'FAAC02';
  24. $this->_size = '300x150';
  25. }
  26. protected function dataToString ($data) {
  27. $str = 't:';
  28. $this->max = max($data);
  29. $this->min = min($data);
  30.  
  31. foreach ($data as $value) {
  32. $newValue = round((1 - ($this->max - $value) / ($this->max - $this->min)) * 100, 3);
  33. $str .= $newValue . ',';
  34. }
  35. return substr($str, 0, -1);
  36. }
  37.  
  38. public function setAxis ($rangeY) {
  39.  
  40. $newRange = round($rangeY / ($this->max - $this->min) * 100, 3);
  41.  
  42. $strLabels = '0:';
  43. $strPosition = '0';
  44. for ($a = $this->getFirstOfRange($rangeY); $a <= $this->max; $a += $rangeY) {
  45. $strLabels .= '|' . $a;
  46. }
  47. for ($a = $this->getFirstGrid($rangeY); $a <= 100; $a += $newRange) {
  48. $strPosition .= ',' . $a;
  49. }
  50. $this->_axis = 'y,x';
  51. $this->_axisRange = $strLabels . '|1:|';
  52. $this->_axisPosition = $strPosition;
  53. }
  54.  
  55. public function setGrids ($rangeY) {
  56. $newRangeY = round($rangeY / ($this->max - $this->min) * 100, 3);
  57. $newRangeX = round(100 / (count($this->baseData) - 1), 2);
  58. $this->_grids = $newRangeX . ',' . $newRangeY . ',3,3,0,' . $this->getFirstGrid($rangeY);
  59. }
  60.  
  61. private function getFirstGrid($rangeY) {
  62. return round((1 - ($this->max - $this->getFirstOfRange($rangeY)) / ($this->max - $this->min)) * 100, 3);
  63. }
  64.  
  65. private function getFirstOfRange($rangeY){
  66. for ($pierwszyPodzielny = $this->min; $pierwszyPodzielny <= $this->max; $pierwszyPodzielny++){
  67. if (abs($pierwszyPodzielny) % $rangeY == 0 || $pierwszyPodzielny == 0)
  68. break;
  69. }
  70. return $pierwszyPodzielny;
  71. }
  72.  
  73. }
  74.  
  75. ?>



jest to caly plik LabChartsLine.php

Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 5.10.2025 - 18:00