Jump to content

Output too long


tugg

Recommended Posts

Hi, i've managed to write a script that retrieves an xml file and outputs the contents to html, it works fine but the output is too long, this is my script so far:

 

$bbc = simplexml_load_file('xmlfile.xml'); 
    $bebese = $bbc->xpath('//programme'); //search for all "programme" elements 
    echo "\t<div id=\"listings\">\n"; 
    echo "\t<p class=\"desc\"><b>$fulltime</b> and forward.\n</p><br />"; 
     
    foreach($bebese as $result) {  
    if ($result->end > $myTajm) { 
        echo $i; 
        echo "<div class=\"title\">{$result->title}<p class=\"time\">{$result->start} - {$result->end}</p></div>"; 
        echo "<p class=\"desc\">{$result->desc}</p>"; 
        echo "<p class=\"desc\">For more info: <a onclick=\"window.open(this.href,'newwin'); return false;\" href=\"{$result->infourl}\">{$result->title}</a></p>"; 
        echo "<br />"; 

} 
}

 

But like i said, the output is several pages long, i would like it to "end" after lets say 10 entries, then save the rest for a second and maybe a third page, like action?get=entry?page=2 ..

I was thinking to add something like a $counter, increase it until it's 10, then put out a link to the second page.

 

Can anyone point me in the right direction?

 

cheers

Link to comment
Share on other sites

just throwing this out there but somthing like this should do along the lines you want

 

<?php
$bbc = simplexml_load_file('xmlfile.xml'); 
    $bebese = $bbc->xpath('//programme'); //search for all "programme" elements 
    echo "\t<div id=\"listings\">\n"; 
    echo "\t<p class=\"desc\"><b>$fulltime</b> and forward.\n</p><br />"; 
     $start = $_GET['start']; // this is a line i have added
    foreach($bebese as $result) {  
    if ($result->end > $myTajm) {
    $count = 0;// this is a line i have added
    if ($count > $start && $count < $start + 10){ // this line i have added
         
        echo $i; 
        echo "<div class=\"title\">{$result->title}<p class=\"time\">{$result->start} - {$result->end}</p></div>"; 
        echo "<p class=\"desc\">{$result->desc}</p>"; 
        echo "<p class=\"desc\">For more info: <a onclick=\"window.open(this.href,'newwin'); return false;\" href=\"{$result->infourl}\">{$result->title}</a></p>"; 
        echo "<br />"; 

}
}// this line i have added
if (count == $start + 10){
$new_start = $start + 10 ;
echo '<a href="me.php?start=' . $new_start . '" class="nav">next</a>';
} // this is a line i have added
    $count++;// this is a line i have added 
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.