Search paging

Search paging

offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

i have done a search script and now when i try something to search it give me the frist five rows(beacuse the limit is set to 5 rows per page) related to the search.When i click on the "next page" link it gives me the rows from the hole table instead to continue the rows from the search.

here is the code

<?php         $connection=mysql_connect('localhost', 'root', '***') or die(mysql_error());                 mysql_select_db("database");                           $posts_per_page = 5;        (!$_GET['start']) ? $start = 0 : $start = $_GET['start'];       $query = "SELECT COUNT(*) FROM posts  WHERE Description like '%".$_GET['Search']."%' or Topic like '%".$_GET['Search']."%'";       $result = mysql_query($query) or die (mysql_error());       $row = mysql_fetch_row($result);       $total_records = $row[0];       if (mysql_num_rows($result) > 0 )       {                      if (($total_records > 0) && ($start < $total_records))                      {         $query="SELECT * FROM Posts  WHERE Description like '%".$_GET['Search']."%' or Topic like '%".$_GET['Search']."%' ORDER BY ID desc LIMIT $start, $posts_per_page";       $result = mysql_query($query) or die (mysql_error());                      } include "PrintRows.php"; //next previous page links if ($start >= $posts_per_page) { echo "<a href=".$_SERVER['PHP_SELF']."?start=".($start-$posts_per_page)."> <= $start </a>"; } if ($start+$posts_per_page < $total_records && $start >= 0) {     $sum = $start + 5;   if ($start == 0){             echo "$start - <a href=".$_SERVER['PHP_SELF']."?start=".($start + $posts_per_page)."> $sum => </a>";            }   else   {    echo " -<a href=".$_SERVER['PHP_SELF']."?start=".($start + $posts_per_page)."> $sum => </a>";   } } } ?>

can anyone explain me this code
 (!$_GET['start']) ? $start = 0 : $start = $_GET['start'];



Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
offline
  • igor86  Male
  • Stručni saradnik
    Web programiranje
  • Pridružio: 24 Maj 2006
  • Poruke: 1633

RutiX ::
can anyone explain me this code
 (!$_GET['start']) ? $start = 0 : $start = $_GET['start'];


Uzmi ovaj kod umjesto tog gore

$start = ( $_GET['start'] != '' ? (int) $_GET['start'] : 0);



offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

ok. can you explain the code?

Dopuna: 11 Maj 2007 2:09

i change the code, but still the same problem.

Dopuna: 11 Maj 2007 3:16

i found the problem but dont know how to fix it.

the problem is when i type a text in the search box it will remember it just for the first page but not for the next pages.

So how can i fix this, i should create a variable which will remember the value of the text box.Should i use arrays?

offline
  • Blood  Male
  • Ugledni građanin
  • Pridružio: 26 Jul 2003
  • Poruke: 384
  • Gde živiš: Beograd

Add to the links &search=$_GET['search']

offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

i dont understand you. be more specific

offline
  • Blood  Male
  • Ugledni građanin
  • Pridružio: 26 Jul 2003
  • Poruke: 384
  • Gde živiš: Beograd

echo " -<a href=".$_SERVER['PHP_SELF']."?start=".($start + $posts_per_page)."&search=".$_GET['search']."> $sum => </a>";

offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

thank you.Now it's working.

Ko je trenutno na forumu
 

Ukupno su 1443 korisnika na forumu :: 101 registrovanih, 11 sakrivenih i 1331 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 15694 - dana 01 Feb 2026 12:23

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: 9191vs, AndrejPetar, Anunakiii, Arsenije, Aska, babaroga, Bivan, boj.an, bojank, bokicacar, boro975, BORUTUS, branko87, Buzdovan, ceman, cemix, Clouseau, Coficab, cvrle312, Darko8, Djokislav, DonRumataEstorski, Dragan777, draganl, DrMrPr, dule10savic, Dungorth, eighty-one, gajasvi, Georgius, GUARIN, Herman Terrance Aubrey, igorkozar83, ikan, istina, Jonbonjovi, Kamov, kaput21, Karaula, karevski, Koca Popovic, komenski, kybonacci, laki_bb, Leteća Krofna, Ljusa, Malahit, Manjane, Marko1238, Maschinekalibar, mat, mercedesamg, Mercury, mgolub, Mi lao shu, Milos ZA, Moldovan, nebkv, Nemanja Opalić, niksa517, nisamBot, Ns1975, Pekman, Povratak1912, Prometeus, radza1, read-only, Rebel Frank, RecA, redstar011, repac, rovac, Shajlok, Sir Budimir, Smiljkovich, smuk, Sonic, spalev, srbijaiznadsvega, ssekir75, stalja, stegonosa, tecataki, toni061, TRZH92, tuja, ujke, Utd4ce, Veless, Velički, vensla, Weah88, wize, x-Death-x, XBMC, zdrebac, zmajbre, Zoca, zule2, |_MeD_|, 1107