Tema: Re: PHP paging problema...
Autorius: gopas
Data: 2010-04-07 20:26:56
na va, puiku:) sekmes :)

"exoticdevil" <born4devil@gmail.com> wrote in message news:hpie8b$jtf$1@trimpas.omnitel.net...
> tai jau tikrai :) sorry, nevisiem vienodai proto duota:) kai padaviau 
> kategorijos pavadinima, veikia normaliai! pries tai nesugebejau normaliai 
> postint dvieju kintamuju url'e, neiiskyriau su &, klaidos nemete, tai ir 
> nepagalvojau, nes pirma kart darau :) dekui labai!
> "gopas" <netikras@jamailas.lt> wrote in message 
> news:hpidjs$j9q$1@trimpas.omnitel.net...
>> kazka tu cia nusisnekejai.
>>
>> "exoticdevil" <born4devil@gmail.com> wrote in message 
>> news:hpi4ed$ag6$1@trimpas.omnitel.net...
>>> as pradzioj kur paimu kategorija, tai ji man tik paimt rezultatam, po to 
>>> jau
>>> ji man nereikalinga, kai rodau puslapius, bandziau, niekas 
>>> nepasikeite..:/
>>> "gopas" <netikras@jamailas.lt> wrote in message
>>> news:hph82g$tn2$1@trimpas.omnitel.net...
>>>> $nav .= " <a href=\"$self?page=$page\">$page</a> ";
>>>>
>>>> kai perduodi puslapio numeri, nebeperduodi kategorijos. cia beda 
>>>> sakyciau.
>>>>
>>>> "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 ;
>>>>>>>
>>>>>>> ?>
>>>>>>>
>>>>>
>>> 
>