mostrar imágenes horizntally mediante la extracción de los registros de la base de datos?

  • asad_black
  • Graduate
  • Graduate
  • No Avatar
  • Registrado: Jun 11, 2007
  • Mensajes: 131
  • Loc: pakistan
  • Status: Offline

Nota Agosto 19th, 2009, 10:38 am

Esta es mi página de muestra...!

http://tutioninn.com/wallpaper.php

en el que las imágenes en un programa de tabla en una dirección vertical, pero quiero mostrar que de manera horizontal ..!

como esta página:
http://neosmart.net/gallery/v/wallpaper ... /Textures/

este es mi código de selección de registro de...!

si u haber un mejor código de este código la amabilidad de contestar tan pronto como sea posible.

Código: [ Select ]


$sql = "SELECT * FROM wallpapers ;
$result = mysql_query($sql);

echo "<table border='1' cellpadding='3' cellspacing='3' width='60%'>";
echo "<tr>";

while ($list = mysql_fetch_assoc($result)) {

     {

echo "<td ><a href=\"idpage.php?id=" . $list["id"] . "\"><img src=\"" . $list["w_th"] . "\" ></a></td>";

echo "<td ><a href=\"idpage.php?id=" . $list["id"] . "\">". $list['w_name']. "</a>";
echo "</td>";

}
echo "</tr>";
}
  1. $sql = "SELECT * FROM wallpapers ;
  2. $result = mysql_query($sql);
  3. echo "<table border='1' cellpadding='3' cellspacing='3' width='60%'>";
  4. echo "<tr>";
  5. while ($list = mysql_fetch_assoc($result)) {
  6.      {
  7. echo "<td ><a href=\"idpage.php?id=" . $list["id"] . "\"><img src=\"" . $list["w_th"] . "\" ></a></td>";
  8. echo "<td ><a href=\"idpage.php?id=" . $list["id"] . "\">". $list['w_name']. "</a>";
  9. echo "</td>";
  10. }
  11. echo "</tr>";
  12. }
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Agosto 19th, 2009, 10:38 am

  • devilwood
  • Silver Member
  • Silver Member
  • Avatar de Usuario
  • Registrado: Nov 18, 2007
  • Mensajes: 429
  • Status: Offline

Nota Agosto 20th, 2009, 10:52 am

Try this.

Código: [ Select ]

$sql = "SELECT * FROM wallpapers ;
$result = mysql_query($sql);

echo "<table border='1' cellpadding='3' cellspacing='3' width='60%'>";
echo "<tr>";

while ($list = mysql_fetch_assoc($result)) {

     { // not really sure what these brackets are for ,remove maybe

echo "<td ><a href=\"idpage.php?id=" . $list["id"] . "\"><img src=\"" . $list["w_th"] . "\" ></a></td>";

echo "<td ><a href=\"idpage.php?id=" . $list["id"] . "\">". $list['w_name']. "</a>";
echo "</td>";

} // you should be able to remove this one too


} // ends the while loop for all the table cells
echo "</tr></table>";
/* put ending tag after the while loop so all your <td> will be in one table row */
  1. $sql = "SELECT * FROM wallpapers ;
  2. $result = mysql_query($sql);
  3. echo "<table border='1' cellpadding='3' cellspacing='3' width='60%'>";
  4. echo "<tr>";
  5. while ($list = mysql_fetch_assoc($result)) {
  6.      { // not really sure what these brackets are for ,remove maybe
  7. echo "<td ><a href=\"idpage.php?id=" . $list["id"] . "\"><img src=\"" . $list["w_th"] . "\" ></a></td>";
  8. echo "<td ><a href=\"idpage.php?id=" . $list["id"] . "\">". $list['w_name']. "</a>";
  9. echo "</td>";
  10. } // you should be able to remove this one too
  11. } // ends the while loop for all the table cells
  12. echo "</tr></table>";
  13. /* put ending tag after the while loop so all your <td> will be in one table row */
  • devilwood
  • Silver Member
  • Silver Member
  • Avatar de Usuario
  • Registrado: Nov 18, 2007
  • Mensajes: 429
  • Status: Offline

Nota Agosto 20th, 2009, 10:55 am

Vaya lo siento no ver a su segundo enlace. Necesitas obtener el número de registros y, a continuación, un poco de trabajo para mostrar bucle sin embargo muchas imágenes que desea horizontalmente.

Malos cavar hasta algo. Mal puesto de nuevo si alguien no me pegaba a él.

La actual se acaba de poner a todos en una fila horizontal. Mi error.
  • devilwood
  • Silver Member
  • Silver Member
  • Avatar de Usuario
  • Registrado: Nov 18, 2007
  • Mensajes: 429
  • Status: Offline

Nota Agosto 20th, 2009, 11:33 am

Tal vez algo como esto. En realidad tengo un archivo en la casa donde escribí esta completa que controla el redondeo de la última fila mejor. Decir la última fila sólo tiene 2 imágenes.


Código: [ Select ]

$sql = "SELECT * FROM wallpapers ;
$result = mysql_query($sql);

//set how many images to display horizontally
$pic_per_row = 4;

echo "<table border='1' cellpadding='3' cellspacing='3' width='60%'>";


$num = mysql_num_rows($result);

// number of table rows
$num_tr = ceil($num/$pic_per_row);


while ($list = mysql_fetch_assoc($result)) {

for ($i = 0; $i < $num_tr; $i++) {

echo "<tr>";     

for ($j = 0; $j < $pic_per_row; $j++) {
if ($list["id"] != "") { //handle the last row
echo "<td><a href=\"idpage.php?id=" . $list["id"] . "\"><img src=\"" . $list["w_th"] . "\" ></a></td>";

echo "<td ><a href=\"idpage.php?id=" . $list["id"] . "\">". $list['w_name']. "</a>";
echo "</td>";
} else {

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

}
        }

echo "</tr>";

    }

}
  1. $sql = "SELECT * FROM wallpapers ;
  2. $result = mysql_query($sql);
  3. //set how many images to display horizontally
  4. $pic_per_row = 4;
  5. echo "<table border='1' cellpadding='3' cellspacing='3' width='60%'>";
  6. $num = mysql_num_rows($result);
  7. // number of table rows
  8. $num_tr = ceil($num/$pic_per_row);
  9. while ($list = mysql_fetch_assoc($result)) {
  10. for ($i = 0; $i < $num_tr; $i++) {
  11. echo "<tr>";     
  12. for ($j = 0; $j < $pic_per_row; $j++) {
  13. if ($list["id"] != "") { //handle the last row
  14. echo "<td><a href=\"idpage.php?id=" . $list["id"] . "\"><img src=\"" . $list["w_th"] . "\" ></a></td>";
  15. echo "<td ><a href=\"idpage.php?id=" . $list["id"] . "\">". $list['w_name']. "</a>";
  16. echo "</td>";
  17. } else {
  18. echo "<td></td><td></td>";
  19. }
  20.         }
  21. echo "</tr>";
  22.     }
  23. }

Publicar Información

  • Total de mensajes en este tema: 4 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 168 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC