Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MYSQL] Powtarzające się dane.
-Beginner-
post 21.09.2008, 19:15:06
Post #1





Goście







Witam,
już na wstępie zaznaczam iż jestem początkujący, przeszukałem forum, lecz nie znalazłem rozwiązania mającego zastosowanie w moim problemie.
Przejdźmy do sedna sprawy, zacząłem kleić system newsów jednakże dość szybko napotkałem trudności, mianowicie poniższy kod zamiast wyświetlania po kolei wyników, pobiera cały czas ten sam rekord. Może ktoś z Was zna rozwiązanie tego problemu?

  1. <?php
  2. $max_items = "5";
  3. $query = "SELECT * FROM news ORDER BY date DESC LIMIT $max_items";
  4. $result = mysql_query ($query);
  5.  
  6. while($row=mysql_fetch_assoc ($result)){
  7. $id = $row['id'];
  8. $title = $row['title'];
  9. $date = $row['date'];
  10. $img = $row['img'];
  11. $text = $row['text'];
  12. $author = $row['author'];
  13. }
  14. ?>


Pozdrawiam
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
-Beginner-
post 22.09.2008, 14:16:28
Post #2





Goście







Można powiedzieć, że działa w 50%, bowiem zawartość index.tpl wyświetla się tyle razy ile jest rekordów ( w tym przypadku 4 ), dokładniej to wygląda tak:

I strona:
  1. <?php
  2. $aproject -> assign('texts1', 'jakis tekst   '.$id.'.'.$title.'.'.$date.'.'.$img.'.'.$text.'.'.$author.'   jakis tekst<br />');
  3. $aproject -> assign('texts2', 'jakis tekst  '.$id.'.'.$title.'.'.$date.'.'.$img.'.'.$text.'.'.$author.'   jakis tekst<br />');
  4. ?>

wyświetla:
  1. jakis tekst 20.1.2008-09-21 21:57:34..333.444 jakis tekst
  2. jakis tekst 20.1.2008-09-21 21:57:34..333.444 jakis tekst


II strona:
  1. <?php
  2. $aproject -> assign('texts1', 'jakis tekst   '.$id.'.'.$title.'.'.$date.'.'.$img.'.'.$text.'.'.$author.'   jakis tekst<br />');
  3. $aproject -> assign('texts2', 'jakis tekst  '.$id.'.'.$title.'.'.$date.'.'.$img.'.'.$text.'.'.$author.'   jakis tekst<br />');
  4. ?>

wyświetla:
  1. jakis tekst 19.344.2008-09-21 21:56:13..444.444 jakis tekst
  2. jakis tekst 19.344.2008-09-21 21:56:13..444.444 jakis tekst


III strona:
  1. <?php
  2. $aproject -> assign('texts1', 'jakis tekst   '.$id.'.'.$title.'.'.$date.'.'.$img.'.'.$text.'.'.$author.'   jakis tekst<br />');
  3. $aproject -> assign('texts2', 'jakis tekst  '.$id.'.'.$title.'.'.$date.'.'.$img.'.'.$text.'.'.$author.'   jakis tekst<br />');
  4. ?>

wyświetla:
  1. jakis tekst 18.title.2008-09-21 20:12:30.img.text.author jakis tekst
  2. jakis tekst 18.title.2008-09-21 20:12:30.img.text.author jakis tekst


IV strona:
  1. <?php
  2. $aproject -> assign('texts1', 'jakis tekst   '.$id.'.'.$title.'.'.$date.'.'.$img.'.'.$text.'.'.$author.'   jakis tekst<br />');
  3. $aproject -> assign('texts2', 'jakis tekst  '.$id.'.'.$title.'.'.$date.'.'.$img.'.'.$text.'.'.$author.'   jakis tekst<br />');
  4. ?>

wyświetla:
  1. jakis tekst 16.2222.2008-09-21 19:03:27.2222.22222.2222 jakis tekst
  2. jakis tekst 16.2222.2008-09-21 19:03:27.2222.22222.2222 jakis tekst
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 Wersja Lo-Fi Aktualny czas: 14.08.2025 - 20:15