Menu

Documentation HowTo MYSQL&PHPLOT

Razvan Pop
2010-11-10
2012-09-07
  • Razvan Pop

    Razvan Pop - 2010-11-10

    Hi,

    as you support was very usefull this night, I have another question, an I am
    afraid that this will not be the last one ;-).

    Can you give me a link or the information where I find a documentation who
    PHPLOT is working together?

    I need a documentation or tutorial for beginners.

    I have create a Table with php, by selected the data in a mysql DB.

    Now need to creat the $data for phplot.

    <?php
    require_once ('konfiguration.php'); //Here are the connection Information 
    $db_link = mysql_connect (MYSQL_HOST, MYSQL_BENUTZER, MYSQL_KENNWORT);
    
    //Connetcion to db
    $db_sel = mysql_select_db( MYSQL_DATENBANK )
    or die("Auswahl der Datenbank fehlgeschlagen");
    
    $sql = "SELECT * FROM workstations_history";
    
    $db_erg = mysql_query( $sql );
    if ( ! $db_erg )
    {
        die('Error!: ' . mysql_error());
    }
    echo '<table border="1">';
    echo "<tr>";
    echo "<td>Datum</td>";
    echo "<td>Anzahl </td>";
    echo "</tr>";
    
    while ($row = mysql_fetch_array( $db_erg, MYSQL_ASSOC))
    {
        echo "<tr>";
        echo "<td>". $row['wsh_date'] . "</td>";
        echo "<td>". $row['wsh_anzahl'] . "</td>";
        echo "</tr>";
    }
    echo "</table>";
    
    mysql_free_result( $db_erg );
    
    require 'phplot.php';
    //I need to generate this automatically
    $data = array(array('01.09.2010', 289), array('01.10.2010', 295), array('01.11.2010 ', 276));
    
    $plot = new PHPlot();
    $plot->SetDataValues($data);
    $plot->SetTitle('First Test Plot');
    $plot->SetIsInline(True);
    $plot->SetOutputFile("./temporary.png");
    $plot->DrawGraph();
    
    echo "<img src= './temporary.png'  />";
    echo "<html><body>";
    

    ?>

    Thank you!

    RPOP

     
  • Razvan Pop

    Razvan Pop - 2010-11-10

    sorry,

    I mean

    who PHPLOT is working together

    ? working together with MYSQL

    RPOP

     
  • Razvan Pop

    Razvan Pop - 2010-11-10

    Yes, thank you!

    My problem was that I used teh result from teh SQL query once for teh cration
    of teh table and a second time for the phplot.

    In fact I have to start the query twice, to be able to use the result in both
    (table and phplot)

    Now it's working.

    RPOP

     
  • lbayuk

    lbayuk - 2010-11-10

    Glad it's working, but you should not have to query the database twice.
    (Probably not a good idea anyway, as you might get different results the
    second time.) You can build the PHP data array, row by row, as you loop
    through the query results outputting your table. I also recommend always using
    an ORDER BY clause in the query so you get predictable results.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.