Tema: Re: PHP paging problema...
Autorius: exoticdevil
Data: 2010-04-07 17:20:38
nemanau, kad tai pades, nes tada antram puslapi nebus rezultatu 
vistiek..pameginsiu...
"323" <323@nomail.lt> wrote in message 
news:hph6fr$rkk$1@trimpas.omnitel.net...
> $offset = ($pageNum - 1) * $rowsPerPage;
> $query = " SELECT * FROM items WHERE itemsubcat = '$cat' LIMIT $offset,
>
> sakyciau tas LIMIT tau ir grazina tik tiek, kiek $ofsetas yra ....
> nuimk LIMIT
>
> "exoticdevil" <born4devil@gmail.com> wrote in message 
> news:hph1km$mso$1@trimpas.omnitel.net...
>> nu rezultatus normalius gaunu, bet antro page neatidaro, kai nuimu WHERE 
>> itemsubcat = '$cat'" nuo abieju querry visus rezultatus gerai ispauzdina, 
>> tai klaida padariau sitam dalyke, bet kokia? negi reik is esmes 
>> pasikeisti scripta, querry detis i masyva, o po to ji isskirstyti i 
>> puslapius. Googlej maciau keleta tokiu...
>> "gopas" <netikras@jamailas.lt> wrote in message 
>> news:hph15n$mm1$1@trimpas.omnitel.net...
>>> tai echo $query, ir ziurek kas blogai.
>>>
>>> "exoticdevil" <born4devil@gmail.com> wrote in message 
>>> news:hpg6ft$be7$1@trimpas.omnitel.net...
>>>> Turiu pasidares scriptuka paging, viskas ok veikia,naudoju kituose 
>>>> vietose
>>>> puslapyje,  bet dabar is db lenteles prireike paimti ne visus duomenis, 
>>>> o
>>>> tik kai kuriuos, ir kazko neveikia,tiksliau pusiau veikia, pirma 
>>>> puslapi
>>>> sugeneruoja, o paspaudus ant sekancio nieko nerodo, tarsi isvis 
>>>> paging'o
>>>> nebutu... nesuprantu kur klaida iveliau, su queriu kazkas ne taip
>>>> manau...visa vakara prasedejau, nebelaiko nervai jau, gal kas padesit..
>>>> (sorry del netvarkos)
>>>>
>>>> <?php
>>>>
>>>> $cat = $_GET['cat'];
>>>>
>>>>
>>>> include ('admin/sqlcon.php');
>>>>
>>>> mysql_select_db("shop");
>>>>
>>>> $rowsPerPage = 5;
>>>> $pageNum = 1;
>>>>
>>>> if(isset($_GET['page']))
>>>> {
>>>>    $pageNum = $_GET['page'];
>>>> }
>>>>
>>>> $offset = ($pageNum - 1) * $rowsPerPage;
>>>> $query = " SELECT * FROM items WHERE itemsubcat = '$cat' LIMIT $offset,
>>>> $rowsPerPage";
>>>> $result = mysql_query($query) or die('Error, query failed');
>>>>
>>>> while($row = mysql_fetch_array($result))
>>>> {
>>>>
>>>>    echo $row["itemcode"]. "<br>";
>>>>
>>>>
>>>> }
>>>>
>>>> $query   = "SELECT COUNT(itemsubcat) AS numrows FROM items WHERE 
>>>> itemsubcat
>>>> = '$cat'";
>>>> $result  = mysql_query($query) or die('Error, query failed2');
>>>> $row     = mysql_fetch_array($result, MYSQL_ASSOC);
>>>> $numrows = $row['numrows'];
>>>> $maxPage = ceil($numrows/$rowsPerPage);
>>>> $self = $_SERVER['PHP_SELF'];
>>>> $nav  = '';
>>>>
>>>> for($page = 1; $page <= $maxPage; $page++)
>>>> {
>>>>   if ($page == $pageNum)
>>>>   {
>>>>       $nav .= "[$page]";
>>>>   }
>>>>   else
>>>>   {
>>>>       $nav .= " <a href=\"$self?page=$page\">$page</a> ";
>>>>   }
>>>> }
>>>>
>>>> if ($pageNum > 1)
>>>> {
>>>>    $page  = $pageNum - 1;
>>>> }
>>>>
>>>> if ($pageNum < $maxPage)
>>>> {
>>>>    $page = $pageNum + 1;
>>>> }
>>>> echo $nav ;
>>>>
>>>> ?>
>>>>
>>
>
>