Daten in ein Array importieren. Aber wie?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Daten in ein Array importieren. Aber wie?

    Guten Tag Alle miteinander.

    Ich hoffe Ihr steinigt mich nicht gleich wenn ich als PHP Newbie mit soch einem Thema anfange.

    Aber mal zu meiner Bitte.

    Grober Überblick:
    Ich versuche Daten aus einer Oracle DB über eine API auszulesen und zu verarbeiten. Die Daten sollen Grafisch dargestellt werden.

    Beides ist nicht das Problem.

    Zum Auslesen der Daten nutze ich folgendes Script:
    PHP Code:
    <?php 
              $user
    =$_GET["user"];
    // Initialization
         
    $myARAPI = new ARAPI("***""***""***" ); 
         
    $myARAPI->setserverport"***"1896);
         
    $Fields = array(536870925,536870986); 
         
    $foo=$myARAPI->getlistentrywithfields("DIVE:Logbuch","('536870988' = $user)",$Fields);
    // Logfile leeren
       
    $logfile fopen("log.txt""w");
        
    fclose($logfile);
    // Display each record
         
    echo "<table border=1>";
         echo 
    "<tr><td width=50>TG-Nr.";
           echo 
    "<td width=150>Luftverbrauch Bar/Min.";
           echo 
    "</tr>";
        foreach(
    $foo as $entryID=>$values)
         {
           echo 
    "<tr><td width=50><b>".$values[536870925]."</b>";
           
    $tg=$values[536870925];
           echo 
    "<td width=100><b>".$values[536870986]."</b>";
           
    $air=$values[536870986];
     
    // Logfile schreiben
     
    $logfile fopen("log.txt""a");
        
    $msg "array('$tg', $air),\r\n";
        
    fwrite($logfile$msg); 
        
    fclose($logfile);        
           echo 
    "</tr>";
         }
         echo 
    "</table>";
         
    $myARAPI->termination(); 
    ?>
    Sie werden in der Tabelle ausgegeben und es wird das File geschrieben.
    Das Logfile habe ich etwas vergewaltigt, aber dazu weiter unten.

    Beides brauche ich eigentlich nicht, sondern ich benötige die Daten in einem Array um sie Grafisch darzustellen.

    Die Grafik soll durch folgendes Script erzeugt werden:

    PHP Code:
    <?php
    # Load the PHPlot class library:
    require_once 'phplot.php';
    # Define the data array: Label, the data set.
    # TG Nummer,  Bar pro Min:
    $data = array(
    array(
    '1'2.40), 
    array(
    '2'1.82), 
    array(
    '3'2.27), 
    array(
    '4'1.65), 
    array(
    '5'1.03), 
    ...
    array(
    '73'1.25), 
    array(
    '74'1.25), 
    array(
    '75'1.25), 
    array(
    '76'1.25),
    );
    # Create a PHPlot object which will make a 600x400 pixel image:
    $p = new PHPlot(800400);
    # Use TrueType fonts:
    $p->SetDefaultTTFont('./arial.ttf');
    # Set the main plot title:
    $p->SetTitle('Luftverbrauch im Durchschnitt');
    # Select the data array representation and store the data:
    $p->SetDataType('text-data');
    $p->SetDataValues($data);
    # Select the plot type - bar chart:
    $p->SetPlotType('lines');
    # Define the data range. PHPlot can do this automatically, but not as well.
    //$p->SetPlotAreaWorld(0, 0, 100, 100);
    # Select an overall image background color and another color under the plot:
    $p->SetBackgroundColor('#ffffcc');
    $p->SetDrawPlotAreaBackground(True);
    $p->SetPlotBgColor('#ffffff');
    # Draw lines on all 4 sides of the plot:
    $p->SetPlotBorderType('full');
    # Set a 3 line legend, and position it in the upper left corner:
    $p->SetLegend(array('Bar pro Minute'));
    //$p->SetLegendWorld(0.30, 95);
    # Turn data labels on, and all ticks and tick labels off:
    $p->SetXDataLabelPos('plotdown');
    $p->SetXTickPos('none');
    $p->SetXTickLabelPos('none');
    $p->SetYTickPos('none');
    $p->SetYTickLabelPos('plotleft');
    # Generate and output the graph now:
    $p->DrawGraph();
    ?>
    Jetzt seht Ihr auch warum ich das Logfile so gestaltet habe.

    Aber jetzt mal zu meiner Frage, wie bekomm ich das erste Script so in das zweite integriert, dass ich Ausgabe direkt in das array bekomme. Also ohne Tabelle und ohne Logfile?

    Bei all meinen Versuchen bin ich auf die Nase gefallen.

    Für Anregungen wäre ich sehr dankbar.

    Gruß
    Markus

    edit:
    Ich benutze PHP5 mit xampp auf einem Win2003 Server der Web Edition.
    Last edited by pohlem; 04-12-2009, 14:15. Reason: Ich hatte die Umgebung vergessen anzugeben.

  • #2
    Bau dir einfach $data in der foreach-Schleife auf. Wo ist das Problem?

    Comment


    • #3
      Originally posted by onemorenerd View Post
      Bau dir einfach $data in der foreach-Schleife auf. Wo ist das Problem?
      Kannst Du mir eventuell sagen wie das dann aussehen sollte?
      So komm ich an der Stelle nicht weiter.

      Mag sein, dass ich mich da jetzt total dämlich anstelle. Ich hab es mal so probiert, aber nicht wirklich den Erfolg damit gehabt.
      PHP Code:
          foreach($foo as $entryID=>$values)
           {
             
      $data = array(array("'"$values[536870925]"'"$values[536870986]),);
           } 
      Wäre dankbar wenn Du mir eventuell noch weiter helfen könntest.

      Comment

      Working...
      X