Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php/smarty]Dane z MySQL z Smartach
zlw
post
Post #1





Grupa: Zarejestrowani
Postów: 44
Pomógł: 0
Dołączył: 30.04.2007
Skąd: WWA

Ostrzeżenie: (0%)
-----


Witam.

Chciałem wstawić na stronie opartej na Smartach dane z MySQLa. Nie wiem niestety jak je wstawić do szablonu.

Próbowałem zrobić to w taki sposób:
  1. <?php
  2. define('SMARTY_DIR', 'smarty/');
  3. include "config.php";
  4. $result = mysql_query("SELECT * FROM cms_config")
  5. or die("Niepoprawne zapytanie MySQL");
  6. $setting = mysql_fetch_array($result);
  7. $footer = $setting[footer];
  8. // ładwanie biblioteki Smarty
  9. require_once(SMARTY_DIR . 'Smarty.class.php');
  10.  
  11. $smarty = new Smarty();
  12.  
  13. $smarty->template_dir = 'template/templates/';
  14. $smarty->compile_dir = 'template/templates_c/';
  15. $smarty->config_dir = 'template/configs/';
  16. $smarty->cache_dir = 'template/cache/';
  17. $smarty->assign('footer','$footer');
  18. $smarty->display('index.tpl');
  19. ?>



  1. <TD background="images/index_12.png" width="501" height="370" valign="top">
  2. <p style="margin: 5px 10px; " align="justify">
  3. <font face="Arial" size="1">
  4. {$footer}
  5. </font>
  6. </TD>


Ale wyświetla mi się nie zawartość zmiennej tylko poprostu $setting[footer]
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.12.2025 - 18:00