Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php / mysql], problem z odczytem z bazy
wojtekwro
post
Post #1





Grupa: Zarejestrowani
Postów: 60
Pomógł: 0
Dołączył: 26.04.2007

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


witam mam mały problem z odczytem z bazy poniżej zamieszczam jej strukturę oraz fragment kodu php

  1. CREATE TABLE `newsy` (
  2. `id` int(11) NOT NULL AUTO_INCREMENT,
  3. `tytulpl` text collate utf8_polish_ci NOT NULL,
  4. `tytulde` text collate utf8_polish_ci NOT NULL,
  5. `tytulit` text collate utf8_polish_ci NOT NULL,
  6. `tytulgb` text collate utf8_polish_ci NOT NULL,
  7. `trescpl` text collate utf8_polish_ci NOT NULL,
  8. `trescde` text collate utf8_polish_ci NOT NULL,
  9. `trescit` text collate utf8_polish_ci NOT NULL,
  10. `trescgb` text collate utf8_polish_ci NOT NULL,
  11. `data` int(11) NOT NULL,
  12. `active` int(1) NOT NULL,
  13. PRIMARY KEY (`id`)
  14. ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci AUTO_INCREMENT=5 ;


fragment kodu php
  1. <?
  2. if(isset($_GET['lang'])) $_SESSION['lang']=$_GET['lang']; 
  3. if(!isset($_SESSION['lang'])) $_SESSION['lang']='pl'; 
  4. .
  5. .
  6. .
  7. <br/><h1>Najnowsze informacje:</h1><br>
  8. <!--newsy -->
  9.  
  10. <?php
  11. function shortcut($tresc,$ile)
  12. {
  13. $licz = strlen($tresc);
  14. if ($licz>=$ile)
  15. {
  16. $tnij = substr($tresc," ",$ile);
  17. $txt = $tnij.'...';
  18. }
  19. else
  20. {
  21. $txt = $tresc;
  22. }
  23. return $txt;
  24. }
  25. #
  26. # tutaj deklarujemy ilosc znakow jaka ma nam wyswietlic skrypt
  27. #select tytul".$lang.", tresc".$lang." from tabela;
  28. $ile = 100;
  29. mysql_connect('xxxxxxxxxxxxx');
  30. mysql_select_db("xxxxxxxxxxxxxxx");
  31. $query = mysql_query("select tytul".$lang." as tytul, tresc".$lang." as tresc from newsy WHERE active='1' order by id desc LIMIT 4");
  32. while($row = mysql_fetch_array($query))
  33. {
  34. $temat = $go;
  35. $active = $rekord[5];
  36. $id = $rekord[0];
  37.  
  38. echo '<b>'.$temat.'</b><br/>';
  39. echo shortcut($tresc,$ile);
  40. echo "<br/><a href='pokaz_news.php?news=$id'> więcej >>></a>";
  41. echo '<hr/>';
  42.  
  43. }
  44. echo '<a href="#">starsze wiadomości</a>';
  45. ?>
  46. ?>



Problem polega na zapytaniu do bazy danych, nie mogę wyświetlić takich danych jak tytuł i treść w zależności od $lang. Próbowałem w ten sposób ale nie wyświetla nic:
  1. <?php
  2. $temat = $rekord("tytul")
  3. ?>
prin query wyświetla coś takiego Resource id #2. Prosiłbym o szybkie rozwiązanie problemu.

Pozdrawiam
Wojtek

Ten post edytował wojtekwro 22.02.2008, 17:38:23
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 19.08.2025 - 14:28