Error when using loop(s) with HTML tables and PHP

Hi Experts

I'm facing a problem when trying to use HTML tables in paginations with PHP.

Accordingly with the code.
<body>

<div id="container_principal">
	<div class="row font">
		<div class="col-md-12">
					<h3>Publicações </h3><hr class="hr_titulos"/>

<?php

    if (empty($resultadoPublicacoes))
    {
        echo 'No momento, não encontram-se cadastradas publicações. ';
    }
        echo "<ul class='media-list' id='publicacoes'>";
    ?>
   
      
      <?php       
        foreach ($resultadoPublicacoes as $resultadoPublicacoes)
        {
        ?>

        <table class="tg">   

        <?php
            $imagem = base_url($resultadoPublicacoes->imagem);
            if ($resultadoPublicacoes->imagem == null)
            {
                $imagem = "http:placehold.it/90x120";
            }

         ?>

            <tr>
            <td class="tg-031e" colspan="2" align = "left"> <?php echo "<h4 class='font'>";  echo ucfirst($resultadoPublicacoes->nome);?></td>
            <td class="tg-031e" colspan="2" align = "right">Leia online</td>
            </tr>
                           
            <tr>
            <td class="tg-031e" rowspan="3">
             <?php
                // Imagem
                echo "<a class='pull-left' href='";
                echo base_url("cesanshome/carregando_arquivo/$idpublicacoes");
                echo "'>";
                echo "<img class='media-object' width='90px' height='120px' src='";
                echo $imagem;
                echo "'></a>
				<div class='media-body' id='link_publicacoes'>" // 
            ?>
              <td class="tg-031e" colspan="2"> 
              <?php echo nl2br($resultadoPublicacoes->conteudo) // Sinopse
             ?>
             </td>
             
            <td class="tg-yw4l" rowspan="3"> 
            <?php
                if (!is_null($resultadoPublicacoes->imagem_issuu))
                {
                    // ISSUU
                    echo ('<div data-configid="');
                    echo (ucfirst($resultadoPublicacoes->imagem_issuu));
                    echo ('"');
                    echo ('style="width:270px; height:360px;"');
                    echo ('class="issuuembed"></div>');
                    echo '<script type="text/javascript" src="//e.issuu.com/embed.js" async="true"></script>"';
                ?>
               </td>
               </tr>

                <tr>
                      <td class="tg-yw4l" colspan="2">Baixe o livro grátis</td>
               </tr>    

               <tr>
                    <td class="tg-yw4l">PDF</td>
                    <td class="tg-yw4l">Ebook</td>
               </tr>
                      
           </table>
                
           
           <?php

    
    }
  }
echo "<br/> $paginacao";

?>

					</ul>
			
		</div>
	</div>
</div>

</body>  
</html>

Open in new window


The 1st page is good.
pg01

But when I go to the 2nd.
Pg 02
It's completelly disconfigured.

Any solution?

Thanks in advance!
Eduardo FuerteDeveloper and AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

WebberCommented:
You have to use foreach like this:

foreach ($resultadoPublicacoes as $resultadoPublicaco) {

}

Open in new window


See: http://php.net/manual/en/control-structures.foreach.php

Also your if does not close before your </table> tag. It think it is intended to be closed at line 67?

Like this:

	if (!is_null($resultadoPublicaco->imagem_issuu)) {
		// ISSUU
		echo ('<div data-configid="');
		echo (ucfirst($resultadoPublicacoes->imagem_issuu));
		echo ('"');
		echo ('style="width:270px; height:360px;"');
		echo ('class="issuuembed"></div>');
		echo '<script type="text/javascript" src="//e.issuu.com/embed.js" async="true"></script>"';
	}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eduardo FuerteDeveloper and AnalystAuthor Commented:
You are right... at line 67 I didn't close the brackets.

Thank you very much!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.