gpt4 book ai didi

php - 表格中的图片

转载 作者:行者123 更新时间:2023-11-29 08:50:55 24 4
gpt4 key购买 nike

我正在使用 PHP 和 MySQL(html 和 CSS 没什么大不了的),我想收集我上传的图像(路径在 MySQL 中)并将它们放入表中。想象一个 5 列 6 行的表格(总共 30 张图片)。我希望最新的图片位于第一列的第一行 - 因此位于左侧和顶部 - 我希望最旧的图片位于最后一列的最后一行 - 因此位于右侧和底部 - -.

index.php

<?php
//Put all required/included files in here
require_once('config.php');

//Connection to database
$link = mysql_connect(DB_HOST,DB_USER,DB_PASS);
if(!$link) {
die('Connection failed: ' . mysql_error());
}

//Select which database to use
$db = mysql_select_database(DB_NAME);

if(!$db) {
die("Database selection failed: " . mysql_error());
}
?>

config.php

<?php
define('DB_HOST','host');
define('DB_USER','user');
define('DB_PASS','pass');
define('DB_NAME','name');
?>

现在,SQL 布局:

layout.sql

CREATE TABLE 'fotos'(
id int not null,
locatie_thumb text not null,
locatie_middel text not null,
locatie_groot text not null,
primary key(id)
);

CREATE TABLE 'tekst'(
id int not null auto_increment,
titel text not null,
bijschrift text not null,
album text not null,
datum DATE not null,
primary key(id)
);

表格背后的想法是,我通过上传表单上传图片,然后输入titel、bijschrift、album、datum 值,然后 MySQL 创建一个 ID。然后我想使用该 ID 将 tekstfotos 链接到表中。

当我希望最新的图片位于左上,最旧的图片位于右下时,如何从MySQL中收集30个最新条目并将它们排列在5列6行的表格中?

最佳答案

你尝试过吗:

SELECT *
FROM fotos, tekst
WHERE fotos.id=tekst.id
ORDER BY tekst.datum DESC
LIMIT 30

如果这是一对一的关系,那么为什么不将它们全部放在同一个表中

关于php - 表格中的图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11260943/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com