<!-- * Retorna <TR> cores diferentes * Copyright (C) 2004 * * Vers�o 0.0.1 * * CHANGELOG * * THIS SCRIPT IS COPYLEFTed, BUT DO NOT REMOVE CREDITS BELOW * * Luiz Miguel Axcar (lmaxcar@yahoo.com.br) * http://www.geocities.com/lmaxcar * Campinas, S�o Paulo, Brasil * PHP [penguin] never sleeps. * * Permission to use and modify this software and its * documentation for any purpose other than its incorporation * into a commercial product is hereby granted WITHOUT FEE, * as long as the AUTHOR IS NOTIFIED that this piece of software * is being used in other applications. * Permission to copy and distribute this software and its * documentation only for non-commercial use is also granted * without fee, provided, however, that the ABOVE COPYRIGHT * notice and the manual appear in all copies, that both that * copyright notice and this permission notice appear in supporting * documentation. The author makes NO REPRESENTATIONS about the * suitability of this software for any purpose. It is * provided "as is", without express or implied warranty. * ALL MODIFICATIONS MUST BE SEND TO THE AUTHOR. --> <?php $_CONEXAO = mysql_connect($host,$user,$pass); mysql_select_db($banco); //uma alternativa seria incluir o arquivo disposto em http://www.phpbrasil.com/scripts/script.php/id/1311 //o script definiria as vari�veis e n�o criaria duplicidade de configura��o de banco $query = "SELECT * FROM tbl_cliente"; $resultado = mysql_query($query,$_CONEXAO); if (mysql_num_rows($resultado)) //se tiver registros... N�o fazendo isso erro pode ser mostrado ao usu�rio { echo "<table>"; while ($campo = mysql_fetch_array($resultado) //loop por todos os registros, explodindo em array associativa com chave_array = nome_campo { $nome = $campo['nome']; $cidade = $campo['cidade']; // d�vidas sobre ++$i consulte http://br.php.net/manual/pt_BR/language.operators.increment.php $cor = (is_int (++$i/2)) ? "#FFFFFF" : "#FFDDDD"; // se tiver d�vidas sobre o uso de operadores trin�rios modelo $variavel = (expressao1) ? expressao2 : expressao3; consulte: // http://br.php.net/manual/pt_BR/language.operators.comparison.php echo "<tr> <td bgcolor='$cor'> $nome - $cidade </td> </tr>"; } echo "</table>"; } ?>