[PHP] Datenbank auslesen (Prado Frameworks)

Dieses Thema im Forum "Webentwicklung" wurde erstellt von uRph03n1x, 10. Oktober 2007 .

  1. 10. Oktober 2007
    Datenbank auslesen (Prado Frameworks)

    Hi Leute,

    habe folgendes Problem bei einer Projektarbeit. Das ganze wurde mit php erstellt mit basis der prado frameworks (pflicht -.-) naja ich bin schon sowet gekommen daten in die mysql datenbank einzulesen und sie auch auszugeben wieder (zum testen) aber ich bekomm es einfach nicht hin sie geordnet auszugeben. das man halt für jeden datensatz eine eigene Zeite erstellt so wie in meinem beispiel oben. Guckt euch das mal bitte an auf der View Seite ist oben eine tabelle dadrin soll jeder datensatz zeile für zeile ausgegeben werden.

    http://urph03n1x.homeftp.net/prado/projekt/

    Um zu prüfen ob denn ne verbindung besteht hab ich den befehl dataBind(); verwendet... so gibt er mir alles auf einmal aus.... nur soll das jetzt strukturiert sein.

    Folgende Quelltexte habe ich verwendet:

    View.page (net wundern die template seiten haben bei prado die .page endung für diejenigen die es nicht kennen ^^)

    PHP:
    < html >
    <
    head >
      <
    title > User Database </ title >
      <
    style >
             .
    Stil_font_header  { font - family : Arial Verdana font - size : "25px"  };
             .
    Stil_font_text  { font - family : Arial Verdana font - size : "12px"  };
             .
    Stil_font_text_small  { font - family : Arial Verdana font - size : "10px"  };
      </
    style >
    </
    head >
    <
    body bgcolor = "CECECE" >
    <
    com : TForm >
          <
    center >< span  class= "Stil_font_header" > User Database View </ p >< b >-</ b ></ span ></ center >
          <
    hr size = "1" >
          <
    center >< span  class= "Stil_font_text" >< b > Navigation : </ b >| < a href = "?page=view" > View User </ a > | < a href = "?page=add" > Add User </ a > |</ span ></ center >
          <
    hr size = "1" >

          <
    table border = "0"  cellspacing = "1"  cellpadding = "5"  bgcolor = "#000000" >
          <
    tr >
          <
    td colspan = "16"  bgcolor = "#EEEEEE" > < span  class= "Stil_font_text" >< center >< b > Overview </ b ></ center ></ span ></ td >
          </
    tr >

          <
    tr >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > ID </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > Supplier </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > Carrier </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > City </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > Building </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > Bandwidth </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > Technology </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > Firewall </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > Network </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > ITContact </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > Phone </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > EMail </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > PostalAdress </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > Comments </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > Edit </ center ></ b ></ span ></ td >
          <
    td bgcolor = "#EEEEEE" >< span  class= "Stil_font_text_small" >< b >< center > Delete </ center ></ b ></ span ></ td >

          </
    tr >

          <
    tr >
          <
    td bgcolor = "#FFFFFF" >< span  class= "Stil_font_text" >< com : TTextBox ID = "ID"  Columns = "1" /></ span ></ td >
          <
    td bgcolor = "#FFFFFF" >< span  class= "Stil_font_text" >< com : TTextBox ID = "Supplier"  Columns = "5" /></ span ></ td >
          <
    td bgcolor = "#FFFFFF" >< span  class= "Stil_font_text" >< com : TTextBox ID = "Carrier"  Columns = "5" /></ span ></ td >
          <
    td bgcolor = "#FFFFFF" >< span  class= "Stil_font_text" >< com : TTextBox ID = "City"  Columns = "5" /></ span ></ td >
          <
    td bgcolor = "#FFFFFF" >< span  class= "Stil_font_text" >< com : TTextBox ID = "Building"  Columns = "5" /></ span ></ td >
          <
    td bgcolor = "#FFFFFF" >< span  class= "Stil_font_text" >< com : TTextBox ID = "Bandwidth"  Columns = "5" /></ span ></ td >
          <
    td bgcolor = "#FFFFFF" >< span  class= "Stil_font_text" >< com : TTextBox ID = "Technology"  Columns = "5" /></ span ></ td >
          <
    td bgcolor = "#FFFFFF" >< span  class= "Stil_font_text" >< com : TTextBox ID = "Firewall"  Columns = "5" /></ span ></ td >
          <
    td bgcolor = "#FFFFFF" >< span  class= "Stil_font_text" >< com : TTextBox ID = "Network"  Columns = "5" /></ span ></ td >
          <
    td bgcolor = "#FFFFFF" >< span  class= "Stil_font_text" >< com : TTextBox ID = "ITContact"  Columns = "5" /></ span ></ td >
          <
    td bgcolor = "#FFFFFF" >< span  class= "Stil_font_text" >< com : TTextBox ID = "Phone"  Columns = "5" /></ span ></ td >
          <
    td bgcolor = "#FFFFFF" >< span  class= "Stil_font_text" >< com : TTextBox ID = "EMail"  Columns = "5" /></ span ></ td >
          <
    td bgcolor = "#FFFFFF" >< span  class= "Stil_font_text" >< com : TTextBox ID = "Postal"  Columns = "5" /></ span ></ td >
          <
    td bgcolor = "#FFFFFF" >< span  class= "Stil_font_text" >< com : TTextBox ID = "Comments"  TextMode = "MultiLine"
               
    Rows = "2"
               
    Columns = "10"   /></ span ></ td >
          <
    td background = "green.jpg" >< span  class= "Stil_font_text" >< com : TButton Text = "Edit"  OnClick = "editButtonClicked"  /> </ span ></ td >
          <
    td background = "red.jpg" >< span  class= "Stil_font_text" >< com : TButton Text = "Delete"  OnClick = "deleteButtonClicked"  /> </ span ></ td >
          </
    tr >
          
          </
    table >
          <
    com : TDataGrid
               ID
    = "grid"
               
    />
          </
    com : TForm >
    </
    body >
    </
    html >
    View.php:
    PHP:
    <?
    class 
    view  extends  TPage
    {

        public function 
    onLoad ( $param )
        {
            
    parent :: onInit ( $param );
            if(!
    $this -> IsPostBack )   // if the page is initially requested
              
    $this -> getData ();

        }

        public function 
    getData (){
          
          
    // Retrieves the existing user data. This is equivalent to:
                // $userRecord=$this->getUserRecord();
                
    $userRecord  = new  PostRecord ;
                
    $user  $userRecord -> findAll ();


                
    // Populates the input controls with the existing user data
                /*
                $this->id->setText('hallo');//=$userRecord->id;
                $this->Supplier->Text=$userRecord->Supplier;
                $this->Carrier->Text=$userRecord->Carrier;
                $this->City->Text=$userRecord->City;
                $this->Building->Text=$userRecord->Building;
                $this->Bandwidth->Text=$userRecord->Bandwidth;
                $this->Technology->Text=$userRecord->Technology;
                $this->Firewall->Text=$userRecord->Firewall;
                $this->Network->Text=$userRecord->Network;
                $this->ITContact->Text=$userRecord->ITContact;
                $this->Phone->Text=$userRecord->Phone;
                $this->EMail->Text=$userRecord->EMail;
                $this->Postal->Text=$userRecord->Postal;
                $this->Comments->Text=$userRecord->Comments;*/
                
    $this -> grid -> DataSource  $user ;
                
    $this -> grid -> dataBind ();

          
        }
    }
    ?>
    ActiveRecord:
    PHP:
    <? PHP

    class  PostRecord  extends  TActiveRecord
    {
        const 
    TABLE = 'benutzerverwaltung' ;
        public 
    $id ;
        public 
    $Supplier ;
        public 
    $Carrier ;
        public 
    $City ;
        public 
    $Building ;
        public 
    $Bandwidth ;
        public 
    $Technology ;
        public 
    $Firewall ;
        public 
    $Network ;
        public 
    $ITContact ;
        public 
    $Phone ;
        public 
    $EMail ;
        public 
    $Postal ;
        public 
    $Comments ;
     
        public static function 
    finder ( $className = __CLASS__ )
        {
            return 
    parent :: finder ( $className );
        }
    }

    ?>

    Application.xml:
    PHP:
    <? xml version = "1.0"  encoding = "utf-8" ?>

    <application id="Project" mode="Debug">

      <paths>
        <using namespace="Application.database.*" />
     </paths>
     



    <modules>
      <module id="db" class="System.Data.TDataSourceConfig">
        <database ConnectionString="mysql:host=localhost;dbname=the1cr" Username="root" Password="mypwd" />
      </module>
        <module class="System.Data.ActiveRecord.TActiveRecordConfig" ConnectionID="db" EnableCache="true" />
    </modules>

      <!-- configuration for available services -->
      <services>
        <service id="page" class="TPageService" DefaultPage="Home" />
      </services>

      <!-- application parameters
      <parameters>
        <parameter id="param1" value="value1" />
        <parameter id="param2" value="value2" />
      </parameters>
      -->
    </application>
    wäre sehr schön wenn mir einer das richten kann das er die daten auf der VIEW page richtig oben in der Tabelle ausgibt.... ohne TTextBox Felder sondern als text... muss ich im template noch umändern ^^

    Bin für jede Hilfe dankbar.

    Achja... Button Edit und Delete können ignoriert werden... wer delete gleich mit einbindet wäre toll aber EDIT brauch auf keinen fall

    Gruß
    uRph03n1x
     
  2. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.