Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MYSQL] Złożone zapytanie
sebekzosw
post
Post #1





Grupa: Zarejestrowani
Postów: 437
Pomógł: 42
Dołączył: 16.04.2007

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


Witam :-)

Mam taki fragment kodu polegającym na dodaniu do tablicy newsów:

  1. <?php
  2. $result = mysql_query("SELECT * FROM news ORDER BY date DESC LIMIT 0,10");
  3. while($row = mysql_fetch_array($result)) {
  4. $new['title'] = nl2br(stripslashes($row['title']));
  5. $new['content'] = nl2br(stripslashes($row['content']));
  6. $new['full_version'] = nl2br(stripslashes($row['full_version']));
  7. $new['date'] = $row['date'];
  8. $user = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE id='".$row['author']."'"));
  9. $new['author'] = stripslashes($user['login']);
  10. $news[] = $new;
  11. }
  12. ?>


Jak zrobić to jednym zapytaniem (i pozbyć się tego
  1. <?php
  2. $user = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE id='".$row['author']."'"));
  3. ?>
(IMG:style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post

Posty w temacie
- sebekzosw   [PHP][MYSQL] Złożone zapytanie   11.10.2009, 10:23:07
- - grn   Musisz złączyć tabele: LEFT JOIN   11.10.2009, 10:30:52


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: 27.09.2025 - 02:30