Visualizzazione dei risultati da 1 a 6 su 6

Discussione: jpgraph e mysql

  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2001
    residenza
    rimini, san marino
    Messaggi
    934

    jpgraph e mysql

    Ciao a tutti.

    Sto cercando di utilizzare jpgraph con mysql

    In pratica ho una query di questo tipo:

    $query= "select fatturato_1 from $nome_tabella";

    e ho una lista di valori che sono le coordinate:

    $datay=array(4,13,30,28,12,45,30,12,55,3,0.5);

    come faccio per tirare fuori i valori del mio array della select in questo modo?

    Grazie dell'aiuto,
    Ale

  2. #2
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    codice:
    $query= "SELECT fatturato_1 FROM $nome_tabella";
    $st = mysql_query( $query ) or die( mysql_error() );
    while ( $row = mysql_fetch_assoc( $st ) )
    {
    	$datay[] = $row['fatturato_1'];
    }

    think simple think ringo

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2001
    residenza
    rimini, san marino
    Messaggi
    934
    L'ho provato.

    Non funziona.

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /srv/www/linekit/htdocs/contenuti_speciali/statistiche_ordinato/grafico_confronto_2.php on line 24
    JpGraph Error Empty input data array specified for plot. Must have at least one data point.


    Ale

  4. #4
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    Originariamente inviato da pig_org
    L'ho provato.

    Non funziona.

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /srv/www/linekit/htdocs/contenuti_speciali/statistiche_ordinato/grafico_confronto_2.php on line 24
    JpGraph Error Empty input data array specified for plot. Must have at least one data point.


    Ale
    controlla che la query venga eseguita correttamente...
    think simple think ringo

  5. #5
    Utente di HTML.it
    Registrato dal
    Jul 2001
    residenza
    rimini, san marino
    Messaggi
    934
    La query funzia.

    Ecco il codice che ho inserito:

    codice:
    <?php
    include ("/srv/www/htdocs/jpgraph/src/jpgraph.php");
    include ("/srv/www/htdocs/jpgraph/src/jpgraph_line.php");
    include ("/srv/www/htdocs/jpgraph/src/jpgraph_bar.php");
    
    $zona="2";
    
    
    $connessione = mysql_connect ($host , $user, $password);
    
    $query= "select fatturato_1,descrizione_linea from $nome_tabella where codice_agente='$zona'";
    
    $query_risultato = mysql_db_query ($nome_database, $query , $connessione);
    
    $st = mysql_query( $query ) or die( mysql_error() );
    while ( $row = mysql_fetch_assoc( $st ) )
    
    {
        $datay[] = $row['fatturato_1'];
        $datax[] = $row['descrizione_linea'];
    }
    
    
        $graph = new graph(580,400,"auto");
        $graph->setscale("textlin");
    
    $bplot = new BarPlot($datay);
    $bplot->SetFillColor("orange");
    
    $graph->Add($bplot);
    
    $graph->Stroke();
    ?>
    Il problema è che oltre non funzionare correttamente mi da anche questo messaggio:

    codice:
    JpGraph Error: HTTP headers have already been sent. 
    Explanation:
    HTTP headers have already been sent back to the browser indicating the data as text before the library got a chance to send it's image HTTP header to this browser. This makes it impossible for the library to send back image data to the browser (since that would be interpretated as text by the browser and show up as junk text).
    Most likely you have some text in your script before the call to Graph::Stroke(). If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser. 
    
    For example it is a common mistake to leave a blank line before the opening "<?php".
    Cosa vuol dire?

    Ale

    1

  6. #6
    Utente di HTML.it L'avatar di nicola75ss
    Registrato dal
    Nov 2004
    Messaggi
    12,922
    Vuol dire che è già stato inviato qualche output al browser o come dice nell'ultima riga del tuo errore che magari hai lasciato una riga vuota o anche un semplice spazio nel codice.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.