输出到3列表以排列图库的问题 [英] Problems outputting to a 3 column table in order to crate an image gallery

查看:59
本文介绍了输出到3列表以排列图库的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我正在尝试查询MySQL数据库(包含图像数据)并在HTML表格中输出结果

为了创建一个基本的缩略图库,我可以查询并输出数据作为一个3列宽(然而它需要很多行... / b $ b需要)。单列表,但是我有填写3列表的问题
(使用不同的图像,循环

连续到最后)。


我很感激,如果有人可以看看下面的代码并且

指向我正确的方向或建议任何额外的代码行

会完成这项工作吗?


下面的代码在每一行上放置一个图像,而不是在

上填充3列,每行有不同的图像。


我打开这个画廊,转到

mywebsite.com/gallery.php?imagetype=landscape(即访问景观

gallery)。


Tha nk你有任何帮助,


Ste

<?php

include(" my_db_login.inc");


$ connection = mysql_connect($ host,$ user,$ password)或死(无法连接

到服务器);

$ db = mysql_select_db($ database,$ connection)或死(无法选择

数据库);


$ title ="图库" ;;

$ query =" SELECT * FROM mydatabase WHERE imagetype =

\" {$ _ GET [''imagetype'' ]} \"" ;;

$ result = mysql_query($ query)或die(无法执行查询。);


echo"< h2> $ title< / h2>" ;;

echo"< table>";

echo"< tbody>" ;;


while($ row = mysql_fetch_array($ result))


{

extract ($ row);

echo"< tr>" ;;

echo"< td>< img src = \" $ imagelocation\" /> \ n

< / td> \ n" ;;

}


echo"< / tr>" ;;

echo"< / table> \ n";

?>

Hi there,

I''m trying to query a MySQL database (containing image data) and to output
the results in a HTML table of 3 columns wide (and however many rows it
takes) in order to create a basic thumbnail gallery.

I can query and output the data as a single column table, but I''m having
problems filling up a 3 column table (with different images, looping
continuously until the end).

I would appreciate it if someone could take a look at the code below and
point me in the right direction or suggest any extra lines of code which
would finish the job?

The code below puts an image on each row, instead of filling up 3 columns on
each row with a different image.

I open this gallery by going to
mywebsite.com/gallery.php?imagetype=landscape (i.e. to access the landscape
gallery).

Thank you for any help,

Ste
<?php
include("my_db_login.inc");

$connection = mysql_connect($host,$user,$password) or die ("couldn''t connect
to server");
$db = mysql_select_db($database,$connection) or die ("Couldn''t select
database");

$title = "Gallery";
$query = "SELECT * FROM mydatabase WHERE imagetype =
\"{$_GET[''imagetype'']}\"";
$result = mysql_query($query) or die ("Couldn''t execute query.");

echo "<h2>$title</h2>";
echo "<table>";
echo "<tbody>";

while ($row = mysql_fetch_array($result))

{
extract($row);
echo "<tr>";
echo "<td><img src=\"$imagelocation\" />\n
</td>\n";
}

echo "</tr>";
echo "</table>\n";
?>

推荐答案

connection = mysql_connect(
connection = mysql_connect(


host,


user,


这篇关于输出到3列表以排列图库的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆