Simple question to php gurus about pagination

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Andreweb
    Confirmed User
    • Mar 2013
    • 2431

    #1

    Simple question to php gurus about pagination

    My php skills are very limited (I'm still learning) ! So there's a chance to paginate this thing ?

    Code:
    <?php
    $xml = simplexml_load_file("camsx.xml");
    foreach($xml->children() as $child){
        $gal[$child->getname()] = $child[0];
        
        foreach($child as $ch){
            $gal[$ch->getname()] = $ch[0];
        
        }
        if($gal['sex']=="Female" && $n < 1000 && $gal['showmode'] == "free"){
        ?><div id="grid">	<div class="host_box">
        <a href="/<? echo $gal['screenname']; ?>" target="_self" "><img src="<? echo $gal['liveimage']; ?>" alt="<? echo $gal['screenname']; ?>"><br>
        <? echo $gal['screenname']; ?></a>
        </div>
        <?php
        $n++;
        }
    }
    ?></div>
    It's just a way I found to parse cams from a XML feed and works just fine but I want to paginate that if is possible any help will be appreciated ! Thanks in advance !
    Make Money With: Chaturbate
    Cheap Reliable Hosting
  • porn-update
    Confirmed User
    • Apr 2014
    • 423

    #2
    I'm not sure I understood what you want to do, but some time ago I did something similar to a paging putting a counter inside the foreach

    Code:
    <?php
    $xml = simplexml_load_file("camsx.xml");
    foreach($xml->children() as $child){
        $gal[$child->getname()] = $child[0];
        
        foreach($child as $ch){
            $gal[$ch->getname()] = $ch[0];
        
        }
        if($gal['sex']=="Female" && $n < 1000 && $gal['showmode'] == "free"){
    /////////////////////
    $start = $_GET['start'];
    $stop = $_GET['start']+5;
    if($n > $start && $n < $stop){
    ///////////////////////////////
        ?><div id="grid">	<div class="host_box">
        <a href="/<? echo $gal['screenname']; ?>" target="_self" "><img src="<? echo $gal['liveimage']; ?>" alt="<? echo $gal['screenname']; ?>"><br>
        <? echo $gal['screenname']; ?></a>
        </div>
        <?php
    ////////////////////
    }
    ////////////////
        $n++;    
    }
    }
    ?></div>
    $start in my case is passed in GET.
    Load anyway the whole xml, but shows only a few lines of output

    Comment

    • Andreweb
      Confirmed User
      • Mar 2013
      • 2431

      #3
      Thanks for your help ! That may work on my site with some changes !
      Make Money With: Chaturbate
      Cheap Reliable Hosting

      Comment

      • celandina
        Too lazy to set a custom title
        • Jun 2006
        • 11728

        #4
        Change this //////////////////////// to this ////////////////// and
        This >>>>><<<<< to this >>>>>>>>>>>/>>>>><<<<

        And do not forget... This :;:;:;:;:;: should read like this ;(:;:;:;:;:;:

        and it will work

        Comment

        Working...