Jump to content
Fórum Script Brasil
  • 0

Alterar Cores Do Resultado Das Consultas (nome Alterado)


Guest --juliano --
 Share

Question

Guest --juliano --

ola pessoal tenho esse codigo e gostaria de saber como faço para exiber o resultado da minha tabela com a linhas com cores diferentes.

esse é o meu script:

<? while($dados=mysql_fetch_array($_base))
   {  
  echo "<tr><td bgcolor='#FFFFCC'>";
  echo $dados["autor"]; echo "<td bgcolor='#FFFFCC'><a href=incluiautor.php?detonar=".$dados["id"].">Deletar</a></td>";
  echo "</td></tr>";
   }
?>

As linhas aparecem tudo na mesma cor, gostaria que fosse exibido cores alternadas.

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

<? while($dados=mysql_fetch_array($_base))

{

$count=1;

if($count%2=0){

$cor="#FFFFCC";

}else{

$cor="#0000FF";

}

echo "<tr><td bgcolor=$cor";

echo $dados["autor"]; echo "<td bgcolor=#FFFFCC'><a href=incluiautor.php?detonar=".$dados["id].">Deletar</a></td>";

echo "</td></tr>";

$count++;

}

?>

Edited by itibere
Link to comment
Share on other sites

  • 0
Guest --Juliano --

Ei amigo esse é meu codico inteiro:

Ainda esta dando alguns erros, sera que você pode me ajudar?


<? session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Incluir Autores</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<?
include("banco.php");
if(isset($_REQUEST['detonar']))
{
mysql_query("delete from localiza where id=".$_REQUEST['detonar']);
}

if(isset($_POST['iautor']))
{
$varautor=$_POST['iautor'];
if($varautor<>"") { mysql_query("insert into localiza (id, autor) values (NULL, '$varautor')"); }

}


$_base=mysql_query("select * from localiza order by autor") or die(mysql_error());

?>
<body background="../imagens/fundo_cinza.jpg">
<table width="625" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="80" bgcolor="#FFFCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="index2.php" target="_self"><img src="../imagens/voltar.jpg" width="80" height="41" border="0"></a>
</font></td>
<td colspan="2" bgcolor="#FFFFCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td colspan="3" bgcolor="#FFCC00"><div align="left"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <font color="#FFCC00"><br>
.....</font><strong><font size="3">Incluir
Autor</font></strong></font></div>
</td>
</tr>
<tr>
<td colspan="3" bgcolor="#FFCC00"><form action="incluiautor.php" method="post" enctype="application/x-www-form-urlencoded" name="basedados" target="_self" id="basedados">
<font size="2"> <font face="Verdana, Arial, Helvetica, sans-serif"> <font color="#FFCC00">....</font>
<input name="iautor" type="text" id="iautor" size="40" maxlength="250">
<input name="bincluir" type="submit" id="bincluir" value="Incluir">
</font></font>
</form>
</td>
</tr>
<tr>
<td colspan="3" bgcolor="#FFCC00" td><font color="#FFCC00" size="1">.</font></td>
</tr>
<tr>
<td colspan="3" bgcolor="#FFCC00" td><strong><font color="#FFCC00" size="2" face="Verdana, Arial, Helvetica, sans-serif">..</font><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">Lista
dos Autores Cadastrados</font></strong></td>
</tr>
<? while($dados=mysql_fetch_array($_base))
{
$count=1;
if($count%2==0){
$cor='#FFFFCC';
}else{
$cor='gremm';
}
echo '<tr><td bgcolor=$cor>';
echo $dados["autor"]; echo "<td bgcolor=$cor><a href=incluiautor.php?detonar=".$dados["id"].">Deletar</a></td>";
echo "</td></tr>";
$count++;
}
?>

</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>[/codebox]

Link to comment
Share on other sites

  • 0
Passe isso:

if($count%2=0){

Para isso:

if($count%2==0){

Foi mal, erro nos sinais;

Mude apossição do $count.

Coloque antes do while;

<?

$count=1;

while($dados=mysql_fetch_array($_base))

{

Edited by itibere
Link to comment
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.

 Share



  • Forum Statistics

    • Total Topics
      150.2k
    • Total Posts
      647.4k
×
×
  • Create New...