• 0
Sign in to follow this  
Guest - proteggere -

Separar Resultado Em Tabelas

Question

Guest - proteggere -

EU GOSTARIA QUE OS CADASTROS FICASEM CADA UM EM UMA TABELA. SEPARADOS POR UM ESPAÇO (<BR>)ENTRE CADA TABELA.

<html>

<head>

<title>Documento sem t&iacute;tulo</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body>

<?php

$conexao=mysql_connect("localhost","agroadm_agroadm","schost123");

mysql_select_db("agroadm_news");

$sql="SELECT * FROM adminnews order by id desc limit 5";

$resultado=mysql_query($sql); ?>

<table width='100%' border='0' cellspacing='1' bgcolor='#004400' align='center'>

<?php

while($pegar=mysql_fetch_array($resultado)) { ?>

<tr>

<td align="left" bgColor='#FFFFF0'><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">

<?php echo "$pegar[titulo]"; ?>

<a href="noticia_detalhada.php?id=<?php echo "$pegar[id]"; ?>">

ler...

</a></font></strong></td>

</tr>

<td width='100%' height='14' bordercolor='#004400'><div align='right'><strong><font color='#FFFFFF' size='1' face='verdana'>Fonte:<?php echo "$pegar[autor]"; ?></font></strong></div></td>

</tr></table>

<?php }

?>

</body>

</html>

DA FORMA QUE ESTA APENAS O PRIMEIRO REGISTRO FICA DENTRO DA TABELA.

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Voce esta abrindo a tabela fora do loop e fechando dentro;

<table width='100%' border='0' cellspacing='1' bgcolor='#004400' align='center'>

<?php

while($pegar=mysql_fetch_array($resultado)) { ?>

></table>

<?php }

Faca assim

<?php

while($pegar=mysql_fetch_array($resultado)) { ?>
<table width='100%' border='0' cellspacing='1' bgcolor='#004400' align='center'>
<tr> 
<td align="left" bgColor='#FFFFF0'><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
<?php echo "$pegar[titulo]"; ?>
<a href="noticia_detalhada.php?id=<?php echo "$pegar[id]"; ?>">
ler...
</a></font></strong></td>
</tr>
<td width='100%' height='14' bordercolor='#004400'><div align='right'><strong><font color='#FFFFFF' size='1' face='verdana'>Fonte:<?php echo "$pegar[autor]"; ?></font></strong></div></td>
</tr></table>
<?php }

Assim ira mostrar uma tabela para cada resultado

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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.

Sign in to follow this