Peter Link Posted May 28, 2012 Report Share Posted May 28, 2012 Boa noite pessoal,Gostaria da ajuda de voces para montar um tabela no php aonde tenho linhas x colunas invertidas.Exemplotable mysqlid - id_reg - coluna - valor 0 - 1 - nome - Peter 1 - 1 - idade - 22 2 - 1 - cidade - curitiba 3 - 1 - estado - parana 4 - 2 - nome - Joao 5 - 2 - idade - 30 6 - 2 - cidade - são Paulo 7 - 2 - estado - são Paulo 8 - 3 - nome - Rita 9 - 3 - idade - 25 10 - 3 - cidade - cascavel 11 - 3 - estado - parana Agora eu precisaria exibir no php da seguinte forma nome - idade - cidade - estado Peter - 22 - curtiba - Parana Joao - 30 - são Paulo - são Paulo Rita - 25 - cascavel - paranaAgradeço desde já Quote Link to comment Share on other sites More sharing options...
0 MTavares Posted May 29, 2012 Report Share Posted May 29, 2012 Não entendi muito bem o que você quer, mas tente fazer dessa forma:Crie um menu fixo<table> <tr> <td>Nome</td><td>Idade</td><td>Cidade</td><td>Estado</td> Depois o laço do seu sistema <?php while($laco = mysql_fetch_object($sql)){ ?> <tr> <td><?php echo $laco->nome; ?></td> <td><?php echo $laco->idade; ?></td> <td><?php echo $laco->cidade; ?></td> <td><?php echo $laco->estado; ?></td> <?php } ?> </tr> </table>Abs. Quote Link to comment Share on other sites More sharing options...
0 Peter Link Posted May 29, 2012 Author Report Share Posted May 29, 2012 beleza valeu a ajuda... vou testar Quote Link to comment Share on other sites More sharing options...
0 mag026 Posted May 29, 2012 Report Share Posted May 29, 2012 Teho um exemplo pronto aqui que exibe produtos cadastrados e so alterar alguns valores mais o codigo já ta mastigado..<?php include "conexao.php"; ?> <body> <form name="form1" id="form1" method="post" action="db.php" /> <table border="0"> <tr> <th scope="col">PRODUTO</th> <th scope="col"> <p> <input tupe="text" name="produto" id="produto" size="40" /> </p> </th> </tr> <tr> <th scope="row">PREÇO</th> <td><input type="text" name="preço" id="preço" size="10" value="R$" /></td> </tr> <tr> <th scope="row"> </th> <td><input type="submit" name="button" id="button" value="cadastrar"/></td> </tr> </table> </form> <hr /> <h1><u>Produtos cadastrados</u></h1> <br /> <table width="30%" border="1"> <tr> <th scope="col">Produto</th> <th scope="col">Valor</th> </tr> <?php $sql = mysql_query("SELECT * FROM cadastro"); while ($listar = mysql_fetch_array($sql)){ $id = $listar['id']; $produto = $listar['produto']; $preço = $listar['preço']; ?> <tr> <th width="45%" scope="col"><?php echo $produto ?></th> <th width="55%" scope="col"><?php echo $preço ?></th> </tr> <?php } ?> </table> Quote Link to comment Share on other sites More sharing options...
Question
Peter Link
Boa noite pessoal,
Gostaria da ajuda de voces para montar um tabela no php aonde tenho linhas x colunas invertidas.
Exemplo
table mysql
Agora eu precisaria exibir no php da seguinte formaAgradeço desde já
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.