Array
(
)

Montando Tabela de acordo com o retorno da consulta

PHP
Jefferson Silva
   - 18 dez 2012

Bom Dia galera
Criando uma tabela e de 9x9 sendo que em cada celula eu retorno uma consulta mysql.
Eu ate consegui fazer porém em cada linha mostra o mesmo resultado
###############------#############---------############
###############------#############---------############
#####ID 1######------#####ID 1###----------#####ID 1###
###############------#############---------############
###############------#############---------############
###############------#############---------############

e eu queria que fosse tipo assim - eu quero usar um laço de repetição porém não to conseguindo chegar na lógica correta.
###############------#############---------############
###############------#############---------############
#####ID 1######------#####ID 2###----------#####ID 3###
###############------#############---------############
###############------#############---------############
###############------#############---------############
###############------#############---------############
###############------#############---------############
#####ID 4######------#####ID 5###----------#####ID 6###
###############------#############---------############
###############------#############---------############
###############------#############---------############
###############------#############---------############
###############------#############---------############
#####ID 7######------#####ID 8###----------#####ID 9###
###############------#############---------############
###############------#############---------############
###############------#############---------############
tem um site exemplo e o site da barrocarte
Segue o Codigo da tabela
#Código

<?php include('Connections/conecao.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>


<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" align="top" valign="top">

    <tr>
        <td height="90%">

    <table width="100%" height="90%" border="0" cellpadding="0" cellspacing="10" align="center" valign="top">
        <tr>
        <?php $sql = mysql_query("SELECT id,titulo,especificacoes,alt,diretorio FROM galeria WHERE id_album =19 LIMIT 21");
		while($ln = mysql_fetch_array($sql)){
        ?>

           <td valign="top" align="center" class="caixa_produto">
                <div id="go">
                <ul id="gop">
                
				 <h2 class="nome_produto"><?php echo utf8_encode( $ln['titulo']);?> (CÓD:<?php echo utf8_encode( $ln['id']);?>)</h2>

                
                
                <center>
<a href="admin/galeria/<?php echo $ln['diretorio']?> <?php $ln['id']?>" class="lightbox" title="<?php echo $ln['titulo']?>">
<img src="admin/galeria/<?php echo utf8_encode( $ln['diretorio']);?> <?php $ln['id']?>" class="imagem_pqn" border="0" alt="<?php utf8_encode( $ln['alt']);?>"  /></a> 
				
				
					
				
				
				</center>
                  
                  <br>
              </li>
            </td>
            <td valign="top" align="center" class="caixa_produto">
                <div id="go">
                <ul id="gop">
                
				 <h2 class="nome_produto"><?php echo utf8_encode( $ln['titulo']);?> (CÓD:<?php echo utf8_encode( $ln['id']);?>)</h2>

                
                
                <center>
<a href="admin/galeria/<?php echo $ln['diretorio']?> <?php $ln['id']?>" class="lightbox" title="<?php echo $ln['titulo']?>">
<img src="admin/galeria/<?php echo utf8_encode( $ln['diretorio']);?> <?php $ln['id']?>" class="imagem_pqn" border="0" alt="<?php utf8_encode( $ln['alt']);?>"  /></a> 
				
				
					
				
				
				</center>
                  
                  <br>
              </li>
            </td>
            <td valign="top" align="center" class="caixa_produto">
                <div id="go">
                <ul id="gop">
                
				 <h2 class="nome_produto"><?php echo utf8_encode( $ln['titulo']);?> (CÓD:<?php echo utf8_encode( $ln['id']);?>)</h2>

                
                
                <center>
<a href="admin/galeria/<?php echo $ln['diretorio']?> <?php $ln['id']?> " class="lightbox" title="<?php echo $ln['titulo']?>">
<img src="admin/galeria/<?php echo utf8_encode( $ln['diretorio']);?> <?php $ln['id']?>" class="imagem_pqn" border="0" alt="<?php utf8_encode( $ln['alt']);?>"  /></a> 
				
				
					
				
				
				</center>
                  
                  <br>
              </li>
            </td> 

            

        </tr>
        
        
        
        
        <?php }?>
       
        <tr> 

        </tr>
    </table>

        </td>
    </tr>
    <tr height="30px">
        <td align="center"><img src="images/pantanal_tema/linha.gif" height="1">
        <div id="container_paginacao">
           
        </div>     
        </td>
    </tr>
</table>
<form method="POST" name="produto" action="carrinho.asp">
    <input type="hidden" name="codigo_produto" value="">
    <input type="hidden" name="codigo_categoria" value="">
    <input type="hidden" name="ato" value="FIM">
    <input type="hidden" name="mode" value="comprar">
</form>
</td>
    </tr>
</table>
</body>
</html>



ta ai o Código se alguém puder me ajudar serei grato. Moderador se eu tiver postado em local incorreto me desculpe e o meu primeiro post.

Felipern
|
MVP
    20 dez 2012

Boa tarde !

Tenta isso aí!

#Código

<?php include('Connections/conecao.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
	<table width="100%" height="100%" border="0" cellpadding="0"
		cellspacing="0" align="top" valign="top">

		<tr>
			<td height="90%">

				<table width="100%" height="90%" border="0" cellpadding="0"
					cellspacing="10" align="center" valign="top">
					<tr>
						<?php 
						$count = 0
						$sql = mysql_query("SELECT id,titulo,especificacoes,alt,diretorio FROM galeria WHERE id_album =19 LIMIT 21");
						while($ln = mysql_fetch_array($sql)){
							?>

						<td valign="top" align="center" class="caixa_produto">
							<div id="go">
								<ul id="gop">

									<h2 class="nome_produto">
										<?php echo utf8_encode( $ln['titulo']);?>
										(CÓD:
										<?php echo utf8_encode( $ln['id']);?>
										)
									</h2>



									<center>
										<a
											href="admin/galeria/<?php echo $ln['diretorio']?> <?php $ln['id']?>"
											class="lightbox" title="<?php echo $ln['titulo']?>"> <img
											src="admin/galeria/<?php echo utf8_encode( $ln['diretorio']);?> <?php $ln['id']?>"
											class="imagem_pqn" border="0"
											alt="<?php utf8_encode( $ln['alt']);?>" />
										</a>





									</center>

									<br>
									</li>
						
						</td>

						<?php if( ($count % 3) == 0){?>
					</tr>
					<tr>
						<?php }?>
						<?php 
						$count++;
						}
						?>
					</tr>

				</table>

			</td>
		</tr>
		<tr height="30px">
			<td align="center"><img src="images/pantanal_tema/linha.gif"
				height="1">
				<div id="container_paginacao"></div>
			</td>
		</tr>
	</table>
	<form method="POST" name="produto" action="carrinho.asp">
		<input type="hidden" name="codigo_produto" value=""> <input
			type="hidden" name="codigo_categoria" value=""> <input type="hidden"
			name="ato" value="FIM"> <input type="hidden" name="mode"
			value="comprar">
	</form>
	</td>
	</tr>
	</table>
</body>
</html>


Qualquer dúvida é só falar.

Jefferson Silva
   - 21 dez 2012

O Felipe Valeu maninho deu certinho so precisei mudar um pedaço do codigo.
mudei esse trecho.
#Código

<?php
$count = 0
$sql = mysql_query("SELECT id,titulo,especificacoes,alt,diretorio FROM galeria WHERE id_album =19 LIMIT 21");
while($ln = mysql_fetch_array($sql)){
?>



para esse

#Código
<?php
$count = 1;
$sql = mysql_query("SELECT id,titulo,especificacoes,alt,diretorio FROM galeria WHERE id_album =19 LIMIT 21");
while($ln = mysql_fetch_array($sql)){
?>


Ou Muito Obrigado e valeu se tiver mais duvidas vou perguntar. rsrsrs