Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MYSQL]Zapytanie do bazy (fetch_assoc)
Victor152
post 31.07.2008, 13:05:26
Post #1





Grupa: Zarejestrowani
Postów: 105
Pomógł: 3
Dołączył: 26.02.2008

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


Witam, zawsze gdy zwracam mysql_fetch_assoc z funkcji i przepuszczam go przez pętlę while otrzymuje nieskończoność razy wypis pierwszego rekordu.
  1. <?php
  2. $get_arr_of = new get_arr_of;
  3. $get_arr_of_cat = $get_arr_of->cat("SELECT * FROM download_cat WHERE id='".ID."' limit 0, ".$get_no_of_file."");
  4. while ($row = $get_arr_of_cat) {
  5. $desc_before = $row['desc'];
  6. if(strlen($desc_before) > 40) {
  7. $desc_before = substr($desc_before, 0, 40);
  8. $desc = $desc_before.'...';
  9. }
  10. else {
  11. $desc = $desc_before;
  12. }
  13. echo $row['name']."<br> ".$desc."<br>";
  14. }
  15. ?>

  1. <?php
  2. class get_arr_of {
  3.  
  4. public function __construct($host = 'localhost', $user = 'root', $pass = '', $db = 'download') {
  5. $this->host = $host;
  6. $this->user = $user;
  7. $this->pass = $pass;
  8. $this->db = $db;
  9. }
  10.  
  11. function cat($query) {
  12. $connection = mysql_connect($this->host, $this->user, $this->pass);
  13. mysql_select_db($this->db, $connection);
  14. $do = mysql_query($query, $connection);
  15. mysql_close($connection);
  16. return mysql_fetch_assoc($do);
  17. }
  18. }
  19. ?>


Macie jakieś pomysły jak to rozwiązac?
Można puścic pętle for, ale to chyba zły i obciążający pomysł?
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: 19.07.2025 - 08:41