Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php&MySql] Pobieranie danych z bazy
patol
post 18.05.2006, 13:34:26
Post #1





Grupa: Zarejestrowani
Postów: 39
Pomógł: 0
Dołączył: 7.05.2004

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


Hej

Mam taki kod pobierajacy dane z bazy i nie wiem dlaczego mi nie dziala, po prostu nic sie nie wyswietla.

  1. <?
  2. include 'inc/baza.php';
  3. $tabela     = "info";
  4. $tabela2    = "galeria";
  5.  
  6.   
  7. if (mysql_connect($sql_serwer, $sql_login, $sql_haslo)  
  8.   and mysql_select_db($sql_baza)) { 
  9.     $wynik1 = mysql_query("SELECT * FROM $tabela WHERE stan='0' ");
  10.   while($wynik1 and $dane1 = mysql_fetch_assoc($wynik1)) { 
  11.  
  12.  
  13. $id = $dane1["id"];
  14. $tytul = $dane1["tytul"];
  15. $tytul2 = $dane1["tytul2"];
  16. $zakres = $dane1["zakres"];    
  17. $dziedzina = $dane1["dziedzina"];
  18. $adres = $dane1["adres"];
  19. $url = $dane1["url"];
  20.  
  21.     
  22.     $wynik2 = mysql_query("SELECT * FROM $tabela2 WHERE nazwa=$id LIMIT 1");
  23.     while($wynik2 and $dane2 = mysql_fetch_assoc($wynik2)) {
  24.  
  25. $zdjecie = $dane2["zdjecie"];
  26.         
  27. ?>
  28.  
  29.     <div id="item">
  30.         <div id="left">
  31.           <a href="index.php?q=2&id=<?=$id?>"><img src="images/<?=$zdjecie?>.jpg" border="0" /></a>
  32.         </div>
  33.         <div id="right" class="width_286">
  34.             <div class="verenda_16_454545">            
  35.             <strong><?=$tytul?></strong> <?=$tytul2?>
  36.             </div>
  37.             <div class="verenda_9_454545_b" style="padding-top:15px;">
  38.             <?=$zakres?>
  39.             </div>
  40.             <div class="verenda_9_454545_b" style="padding-top:8px;">
  41.             <?=$dziedzina?>
  42.             </div>
  43.             <div class="verenda_9_454545" style="padding-top:8px;">
  44.             <?=$opis?>    
  45.             </div>
  46.             <div style="padding-top:8px;">
  47.             <a href="<?=$url?>" target="_blank" class="verenda_9_e74f12" ><?=$adres?></a>
  48.             </div>
  49.             <div style="padding-top:8px;">
  50.             <a href="index.php?q=2&id=<?=$id?>" target="_blank" class="verenda_9_454545">Click image to see more.</a>
  51.             </div>
  52.         </div>    
  53.     </div>
  54.     
  55. <?
  56.  }
  57.      }
  58.      
  59. }
  60. ?>


Ten post edytował patol 18.05.2006, 13:35:21
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
Foxx
post 18.05.2006, 13:39:44
Post #2





Grupa: Zarejestrowani
Postów: 896
Pomógł: 76
Dołączył: 15.11.2003
Skąd: Sosnowiec/Kraków

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


To daj wszędzie
  1. <?php
  2.  
  3. mysql_query("SELECT * FROM $tabela2 WHERE nazwa=$id LIMIT 1") or die (mysql_error());
  4.  
  5. ?>

Może wtedy coś się wyświetli.

Btw.
Raczej:
  1. <?php
  2.  
  3. mysql_query(... WHERE nazwa='".$id."' ... ) ;
  4.  
  5. ?>


Ten post edytował Foxx 18.05.2006, 13:40:41
Go to the top of the page
+Quote Post

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 Wersja Lo-Fi Aktualny czas: 14.08.2025 - 01:55