<?
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('information_schema') or die(mysql_error());
function tableConstructorSimple($tabela,$campos,$cores,$extra,$to){
//monta sql
$sql="SELECT $campos FROM $tabela $extra";
//fim montagem sql
// montagem da tabela
$q=mysql_query($sql);
$table='<fieldset><table width="100%" border="0"><tr>';
//monta título
$acampos=explode(',',$campos);
while(list($k,$f)=each($acampos)){
$table.='<td align="center"><strong>'.strtoupper($f).'</strong></td>';
}//fim while campos
$table.='</tr>';
//monta linhas do resultado
$bcampos=explode(',',$campos);
$num=2;
while($result=mysql_fetch_array($q)){
$index=$num % 2;
$num++;
$cor=$cores[$index];
$table.='<tr bgcolor="'.$cor.'">';
while(list($k,$g)=each($bcampos)){
$dado=$result[$g];
$table.='<td onClick="javascript:location.href=\''.$to.'?'.$g.'='.$dado.'\'">'.$dado.'</td>';
}//fim while colunas
reset($bcampos);
$table.='</tr>';
}//fim while linhas
$table.='</table></fieldset>';
echo $table;
//fim tabela
}//fim função
?>
<html>
<head>
<title>tableConstructor Simple</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<H1>tableCopnstructorSimple</H1>
<H2>Constrói uma tabela automaticamente.</H2>
<H3>Para passar dados para outra página (neste caso, teste.php) apenas clique uma vez no dado que deseja passar.</H3>
<?
//tableConstructor("nome da tabela","campos que vão aparecer na consulta, separados por vírgula",array("cor1","cor2"),"opções extras da consulta (ex.: where group by, etc","página de destino para manipular uma linha escolhida");
tableConstructorSimple("COLLATIONS","ID,COLLATION_NAME,CHARACTER_SET_NAME",array("#CCCCCC","#FFFFFF")," GROUP BY CHARACTER_SET_NAME","teste.php");
?>
</body>
</html>