Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php] odwołanie do klasy
Forum PHP.pl > Forum > Przedszkole
tomi1985
Hej,

wstyd się przyznać ale zapomniałem jak się odwołuje do klasy biggrin.gif


Mam taką klasę i chciałbym się do niej odwołać z innego pliku aby tylko pobrać tablicę z wynikami...

  1. class LoadDate{
  2.  
  3. private $showLoadDate;
  4.  
  5. public function loadDate(){
  6. $query = '
  7. SELECT
  8. ads.idAds, ads.firmName, ads.category, ads.voivodeship, ads.city, ads.postCode, ads.street, ads.text, ads.phone, ads.phone2, ads.webSite, ads.mail, ads.pricing, ads.priceDown, ads.priceUp, ads.map, ads.keywords, ads.active,
  9. city.idCity, city.city,
  10. category.idCategory, category.category,
  11. voivodeship.idVoivodeship, voivodeship.voivodeship
  12. FROM ads
  13. INNER JOIN city on ads.city = city.idCity
  14. INNER JOIN category on ads.category = category.idCategory
  15. INNER JOIN voivodeship on ads.voivodeship = voivodeship.idVoivodeship
  16. WHERE ads.active = 1 AND ads.idAds = "15"
  17. ';
  18.  
  19. $this->so->doit($query);
  20.  
  21. while($this->so->next_record()){
  22. $this->backString = $this->config->generator($firmName,$file);
  23.  
  24. $this->showLoadDate = array (
  25. 'firmName' => $this->so->f('firmName'),
  26. 'city' => $this->so->f('city'),
  27. 'category' => $this->so->f('category'),
  28. 'voivodeship' => $this->so->f('voivodeship'),
  29. 'postCode' => $this->so->f('postCode'),
  30. 'street' => $this->so->f('street'),
  31. 'mail' => $this->so->f('mail'),
  32. 'phone' => $this->so->f('phone'),
  33. 'phone2' => $this->so->f('phone2'),
  34. 'webSite' => $this->so->f('webSite'),
  35. 'priceDown' => $this->so->f('priceDown'),
  36. 'priceUp' => $this->so->f('priceUp'),
  37. 'pricing' => $this->so->f('pricing'),
  38. 'text' => $this->so->f('text')
  39. );
  40. }
  41.  
  42. return $this->showLoadDate;
  43. }
  44. }


pomoże ktoś ?
rad11
  1.  
  2. require_once "LoadDate.php";
  3.  
  4. $loadDate = new LoadDate();
  5. $loadDate->loadDate();
  6.  

tomi1985
thx

hej,

a jak mam tak:

  1. include_once '../db/DbConnect.php';
  2. include_once 'loadDate.php';
  3.  
  4. class Panel {
  5.  
  6. private $db;
  7. private $load;
  8. private $showDate;
  9.  
  10. public function Panel(){
  11. $this-> db = new Dbconnect();
  12. $this-> load = new LoadDate($this->db);
  13. }
  14.  
  15.  
  16.  
  17.  
  18. public function init(){
  19. $this -> showDate = $this->load->load();
  20. echo '<div id="resultChange">
  21. <h4>Dane Obiektu</h4>
  22. <form id="formChange" action="#" method="post">
  23. <table>
  24. <tr>
  25. <td>Ulica</td>
  26. <td><input class="changeDate" type="text" name="street" value="'.$this -> showDate['street'].'" /></td>
  27. <td>Kod Pocztowy</td>
  28. <td><input class="changeDate" type="text" name="postCode" value="'.$this -> showDate['postCode'].'" /></td>
  29. </tr>
  30. <tr>
  31. <td>Kategoria</td>
  32. <td><select class="changeDate" name="category"><option>111111</option></td>
  33. <td>Miejscowość</td>
  34. <td><input class="changeDate" type="text" name="city" value="'.$this -> showDate['city'].'" /></td>
  35. </tr>
  36. <tr>
  37. <td>Województwo</td>
  38. <td><select class="changeDate" name="voivodeship"><option>111111</option></select></td>
  39. <td>Adres strony www</td>
  40. <td><input class="changeDate" type="text" name="url" value="'.$this -> showDate['webSite'].'" /></td>
  41. </tr>
  42. <tr>
  43. <td>Telefon</td>
  44. <td><input class="changeDate" type="text" name="phone" value="'.$this -> showDate['phone'].'" /></td>
  45. <td>Drugi Telefon</td>
  46. <td><input class="changeDate" type="text" name="phone2" value="'.$this -> showDate['phone2'].'" /></td>
  47. </tr>
  48. <tr>
  49. <td>E-mail</td>
  50. <td><input class="changeDate" type="text" name="email" value="'.$this -> showDate['mail'].'" /></td>
  51. <td>Fax</td>
  52. <td><input class="changeDate" type="text" name="fax" value="'.$this -> showDate['fax'].'" /></td>
  53. </tr>
  54. <tr>
  55. <td>Cena od</td>
  56. <td><input class="changeDate" type="text" name="priceDown" value="'.$this -> showDate['priceDown'].'" /></td>
  57. <td>Cena do</td>
  58. <td><input class="changeDate" type="text" name="priceTo" value="'.$this -> showDate['priceTo'].'" /></td>
  59. </tr>
  60. <tr>
  61. <td colspan="4"><label>Cennik<textarea class="changeDate" name="pricing">'.$this -> showDate['pricing'].'</textarea></label></td>
  62. </tr>
  63. <tr>
  64. <td colspan="4"><label>Opis obiektu<textarea class="changeDate" name="text">'.$this -> showDate['text'].'</textarea></label></td>
  65. </tr>
  66. <tr>
  67. <td colspan="4"><input class="submit" type="submit" value="Zapisz Zmiany" /></td>
  68. </tr>
  69. </table>
  70. </form>
  71. </div>';
  72. }
  73. }
  74.  
  75.  
  76. $t = new Panel;
  77. $t -> init();


wszystko ładnie działa ale chciałbym aby kod html był w osobnym pliku...
rad11
To zrób sobie folder views tam utwórz plik z twoim html a później zaincluduj go w to miejsce . Zainteresuje się MVC.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.