Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> wczytywanie rekordu mysql
zero-gravity
post
Post #1





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 9.12.2011

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


Zrobiłem taki kod:

  1. <?php
  2. define('DB_HOST','mysql.cba.pl');
  3. define('DB_USER','sasp1');
  4. define('DB_PASS','marcin');
  5. define('DB_NAME','sasp_cba_pl');
  6. mysql_connect(DB_HOST,DB_USER,DB_PASS,true)or die(mysql_error());
  7.  
  8.  
  9. $query = mysql_query("select * from support order by data desc")or die(mysql_error());
  10.  
  11. echo '<table id="tab">
  12. <tr><th><center>ID </center></th><th>NICK</th><th>WIEK</th><th>Akcja</th></tr>';
  13.  
  14. while($r=mysql_fetch_array($query)){
  15. echo '<tr>';
  16. echo '<td>'.$r['id'].'</td>';
  17. echo '<td>'.$r['pole'].'</td>';
  18. echo '<td>'.$r['nick'].'</td>';
  19. echo '<td><a href="book.php?id='.$r['id'].'"> [Przeczytaj]</A><td>';
  20. echo '</tr>';
  21. }
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. echo '</table>';
  31. ?>



A jak zrobić aby wczytało mi dany rekord? np. book.php?id=1
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
sylwekqaz
post
Post #2





Grupa: Zarejestrowani
Postów: 40
Pomógł: 6
Dołączył: 5.03.2011

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


  1. <?php
  2. define('DB_HOST','localhost');
  3. define('DB_USER','root');
  4. define('DB_PASS','');
  5. define('DB_NAME','sasp_cba_pl');
  6. mysql_connect(DB_HOST,DB_USER,DB_PASS,true)or die(mysql_error());
  7.  
  8. if (isset($_GET['id'])and !empty){
  9. $query = mysql_query("select * from support where id='".intval($_GET['id'])."' order by data desc")or die(mysql_error());
  10. } else {
  11. $query = mysql_query("select * from support order by data desc")or die(mysql_error());
  12. }
  13. echo '<table id="tab">
  14. <tr><th><center>ID </center></th><th>NICK</th><th>WIEK</th><th>Akcja</th></tr>';
  15.  
  16. while($r=mysql_fetch_array($query)){
  17. echo '<tr>';
  18. echo '<td>'.$r['id'].'</td>';
  19. echo '<td>'.$r['pole'].'</td>';
  20. echo '<td>'.$r['nick'].'</td>';
  21. echo '<td><a href="book.php?id='.$r['id'].'"> [Przeczytaj]</A><td>';
  22. echo '</tr>';
  23. }
  24.  
  25. echo '</table>';
  26. ?>

oto kod.
a w pierwszym poście usuń dane do mysql'a
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: 7.10.2025 - 08:29