Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php][mysql]wyświetlanie w osobnej tabeli
Forum PHP.pl > Forum > Przedszkole
jacus24
Mam taki skrypt który pobiera i wyświetla mi dane z tabeli ale, wszystko w jednej co zrobić żeby każde ogłoszenie było w osobnej?
  1. <?php
  2.  $query = "SELECT * FROM ogloszenia ";
  3.  
  4.  $result = mysql_query($query , $link)
  5.  or die(mysql_error());
  6.  $num_ogloszenia = mysql_num_rows($result);
  7. $ogloszenia_header=<<<EOD
  8.  
  9. <table bgcolor="white" width="800" border="1" rules="rows" cellpadding="7"
  10.  cellspacing="2" align="center">
  11. <tr bgcolor="blue" >
  12.  
  13. <th bgcolor="pink" width="20%">Kategoria</th>
  14. <th width="20%">Region</th>
  15. <th width="20%">Miasto</th>
  16. <th>Imię</th>
  17. <th width="20%">Tresć</th>
  18. <th width="20%">Kontakt</th>
  19. </tr>
  20.  
  21. EOD;
  22.  
  23. $ogloszenia_details = '';
  24. while ($row = mysql_fetch_array($result)) {
  25.  
  26. $kategoria = $row['kategoria'];
  27. $region = $row['region'];
  28. $miasto = $row['miasto'];
  29. $imie = $row['imie'];
  30. $tresc = $row['tresc'];
  31. $kontakt = $row['kontakt'];
  32. $ogloszenia_details .=<<<EOD
  33.  
  34. <tr >
  35. <td>$kategoria </td>
  36. <td>$region</td>
  37. <td>$miasto</td>
  38. <td>$imie</td>
  39. <td>$tresc</td>
  40. <td>$kontakt</td>
  41. </tr>
  42.  
  43. EOD;
  44. }
  45.  
  46. $ogloszenia_details .=<<<EOD
  47.  
  48. EOD;
  49.  
  50. $ogloszenia_footer ="</table>";
  51.  
  52. $ogloszenia =<<<OGLOSZENIA
  53. $ogloszenia_header
  54. $ogloszenia_details
  55. $ogloszenia_footer
  56. OGLOSZENIA;
  57.  
  58.  
  59. echo $ogloszenia;
  60.  
  61. ?>
gutek84
Do petli wrzuc tabelke. Cos takiego while(...) {<table>.....</table>;}.
jacus24
kombinuje ale, mam z tym problem:(
Grzyw
  1. <?php
  2.  $query = "SELECT * FROM ogloszenia ";
  3.  
  4.  $result = mysql_query($query , $link)
  5.  or die(mysql_error());
  6.  $num_ogloszenia = mysql_num_rows($result);
  7.  
  8. $ogloszenia_details = '';
  9. while ($row = mysql_fetch_array($result)) {
  10.  
  11. ?>
  12.  
  13. <table bgcolor="white" width="800" border="1" rules="rows" cellpadding="7"
  14.  cellspacing="2" align="center">
  15. <tr bgcolor="blue" >
  16.  
  17. <th bgcolor="pink" width="20%">Kategoria</th>
  18. <th width="20%">Region</th>
  19. <th width="20%">Miasto</th>
  20. <th>Imię</th>
  21. <th width="20%">Tresć</th>
  22. <th width="20%">Kontakt</th>
  23. </tr>
  24. <?php
  25.  
  26. $kategoria = $row['kategoria'];
  27. $region = $row['region'];
  28. $miasto = $row['miasto'];
  29. $imie = $row['imie'];
  30. $tresc = $row['tresc'];
  31. $kontakt = $row['kontakt'];
  32. ?>
  33.  
  34. <tr >
  35. <td>$kategoria </td>
  36. <td><?=$region?></td>
  37. <td><?=$miasto?></td>
  38. <td><?=$imie?></td>
  39. <td><?=$tresc?></td>
  40. <td><?=$kontakt?></td>
  41. </tr>
  42. </table>
jacus24
ok juz poprawiłem i działa:)
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.