Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] Pager
Zeo
post
Post #1





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 9.08.2006

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


Fatal error: Cannot instantiate non-existent class: pager in c:\Windows\render.php on line 9


kod:

  1. <?php
  2.  
  3.  mysql_connect('localhost', 'xxt', 'xx');
  4.  mysql_select_db('xxx');
  5.  $sql = 'select count(*) from profil';
  6.  $result = mysql_query($sql);
  7.  $row = mysql_fetch_array($result);
  8.  $recordsCount = $row[5];
  9.  $pager = new Pager('id');
  10.  $pager->SetTotalRecords($recordsCount);
  11.  $renderPager = $pager->Render(true);
  12.  $start = $pager->GetIndexRecordStart();
  13.  $end = $pager->GetIndexRecordEnd();
  14.  $sql = 'select * from profil limit '.$start.','.($end - $start + 1);
  15.  echo $renderPager ;
  16.  ?>


Pager.class.php jest w tym samym katalogu co ten plik, niemam pojęcia czemu to nie działa sciana.gif

Ten post edytował Zeo 1.03.2008, 12:40:19
Go to the top of the page
+Quote Post
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




no ale musisz te klase dolaczyc:
  1. <?php
  2. require_once('Pager.class.php');
  3. ?>


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
Zeo
post
Post #3





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 9.08.2006

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


Kod
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in c:\Windows\Pager.class.php on line 34


Już wcześniej robiłem require, ale jak widać to nie to.
Go to the top of the page
+Quote Post
Cysiaczek
post
Post #4





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Bo masz php 4. Zainstaluj php 5.


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
nospor
post
Post #5





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Nie musi instalowac php5. Sa tam tez wersje pagera dla php4


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
Zeo
post
Post #6





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 9.08.2006

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


Dobra, ruszyło na php5, poprawiłem trochę kod jednak po uruchomieniu skryptu pokazuje się pusta strona!
oto jak wygląda kod:
  1. <?php
  2.  include_once('Pager.class.php');
  3.  mysql_connect('localhost', 'xxt', 'xxx');
  4.  mysql_select_db('xxx');
  5.  $sql = 'select * from profil';
  6.  $result = mysql_query($sql);
  7.  $row = mysql_fetch_array($result);
  8.  $recordsCount = $row[10];
  9.  $pager = new Pager('id');
  10.  $pager->SetTotalRecords($recordsCount);
  11.  $pager->Make(true);
  12.  $renderPager = $pager->Render();
  13.  $start = $pager->GetIndexRecordStart();
  14.  $end = $pager->GetIndexRecordEnd();
  15.  $sql = 'select * from profil limit '.$start.','.($end - $start + 1);
  16.  echo $renderPager ;
  17.  ?>
Go to the top of the page
+Quote Post
nospor
post
Post #7





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




pager generuje strony jesli jest ich wiecej niz jedna. jesli wiec maszy tylko rekordow na jedna strone to pager nic nie wygeneruje.

Pozatym byloby milo jesli oprocz pagera wyswietlalbys swoje wyniki, czego na chwile obecna nie robisz smile.gif

ps:
  1. <?php
  2. $sql = 'select * from profil';
  3.  $result = mysql_query($sql);
  4.  $row = mysql_fetch_array($result);
  5.  $recordsCount = $row[10];
  6. ?>

hmmm, w pierwszym rekordzie z tabeli profil w polu nr 10 trzymasz liczbe rekordow? dziwne, bardzo dziwne....


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
Zeo
post
Post #8





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 9.08.2006

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


takie coś zrobiłem:
  1. <?php
  2.  include_once('Pager.class.php');
  3.  mysql_connect('localhost', 'xx', 'xxl');
  4.  mysql_select_db('xxxl');
  5.  $sql = 'select count(*) from profil';
  6.  $result = mysql_query($sql);
  7.  $row = mysql_fetch_array($result);
  8.  $recordsCount = $row[0];
  9.  $pager = new Pager('id');
  10.  $pager->SetTotalRecords($recordsCount);
  11.  $pager->Make(true);
  12.  $renderPager = $pager->Render();
  13.  $start = $pager->GetIndexRecordStart();
  14.  $end = $pager->GetIndexRecordEnd();
  15.  $sql = 'select * from profil limit '.$start.','.($end - $start + 1);
  16.  $result = mysql_query($sql);
  17.  $row = array();
  18. while ($row = mysql_fetch_assoc($result)){
  19. $res[] = $row;
  20.  
  21.  }
  22.  echo $renderPager ;
  23.  ?>


Tylko co trzeba tu dopisać że wyświetliły mi sie jakieś wartości nad tym pagerem?
Powiedzmy że tak wygląda struktura mojej bazy:
Id,imie,nazwisko,email,opis
baza ma 40rekordów.
Go to the top of the page
+Quote Post
nospor
post
Post #9





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Pozwole sobie wyodrebnic te posty z mego tematu na przedszkole bo to juz lekka przesada smile.gif

Jak wyswietlic rekordy?
  1. <?php
  2. while ($row = mysql_fetch_assoc($result)){
  3. $res[] = $row;
  4. print_r($row);
  5.  
  6.  }
  7. ?>

I juz sie wyswietla. Ty sobie zrob ladniej.


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
Zeo
post
Post #10





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 9.08.2006

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


dobra dzięki wiem o co chodzi, dalej już sobie poradzę smile.gif
Go to the top of the page
+Quote Post

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: 21.08.2025 - 07:39