Jump to content

foreach help


abrahamgarcia27

Recommended Posts

well i dont want to limit to 5 entries i want to echo 10 entries but after the 5 entry it goes to another table

 

So preety much

<table id=table 1>
echo 'record1'
echo 'record1'
echo 'record1'
echo 'record1'
echo 'record1'
</table

<table id=table 2>
echo 'record1'
echo 'record1'
echo 'record1'
echo 'record1'
echo 'record1'
</table>

 

so preety much after it echos the 5 entries it would go to the other table id

Link to comment
Share on other sites

i have a table that echos 10 entries what i want to do is once it echos 5 records it starts a new table. I dont know how to go about this. Could you guys guide me the right way.

where is the data coming from? Please give us a little more details about the issue, and post relevant code.

Link to comment
Share on other sites

i am using a zend framework youtube so the data is coming from the youtube

 

function echoVideoList($feed)
{   
echo "<h2 style='text-align:left;font-family:Tahoma, Geneva, sans-serif; color:#999;'>Search Results</h2>";
    echo '<table class="videoList">';
    echo '<tbody width="100%">';
    foreach ($feed as $entry) {
        $videoId = $entry->getVideoId();
        $thumbnailUrl = $entry->mediaGroup->thumbnail[0]->url;
        $videoTitle = $entry->mediaGroup->title;
        $videoDescription = $entry->mediaGroup->description;
        print <<<END
        <tr onclick="ytvbp.presentVideo('${videoId}')">
        <td width="130"><img src="${thumbnailUrl}" height="100px" width="100px" />
        <br />
        <a href="#">${videoTitle}</a>

     </td>
        </tr>
END;
    }
    echo '</table>';
}


Link to comment
Share on other sites

sorry how would i do this i am really new to php

 

i found this example i tried applying, but i dont think i am going the right track

 

<html>
<body>
<?php
$array = array( 1, 2, 3, 4, 5);
foreach( $array as $value )
{
  if( $value == 3 )continue;
  echo "Value is $value <br />";
}
?>
</body>
</html>

Link to comment
Share on other sites

Here's a basic example, using the modulus operator . . .

 

<?php
$values = range(1, 21);
echo "<table>\n";
$i = 1;
foreach( $values as $v ) {
   echo "<tr><td>$v</td></tr>\n";
   if( $i % 5 === 0 && $v !== end($values) ) {
      echo "</table>\n<table>\n";
   } elseif ( $v === end($values) ) {
      echo "</table>\n";
   }
   $i++;
}

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.