gpt4 book ai didi

php - 显示来自两个表的信息 php?

转载 作者:行者123 更新时间:2023-11-29 21:54:04 24 4
gpt4 key购买 nike

我在显示 MySQL 数据库中的某些信息时遇到困难。我创建了一个销售页面,该页面有一个前端 GRID 系统,可以显示广告,单击每个广告时,您会获得包含详细信息的内容。

我在 MySQL 中创建了两个表,一个存储所有文本信息,另一个显示一系列链接到 ID 值的多个图像。 (见下文)

Aircraft Sales - Images are stored here

有没有办法显示其中一张图像而不是在该 ID 中显示所有图像?填充网格正面图像?

You can see all the grid system layout (Fine, but I can't get any images to display), when I do I get all images related to that id.

飞机代码。

代码是:

<div id="home" class="main-container">
<div class="content-container">
<div class="container">
<div class="bs-example" data-example-id="thumbnails-with-custom-content">
<h1 style="text-align:left;"><font color="#D60808">Aero-Agent</font>
<small><font color="#909090">Current Stock List</small></font></h1>
<?php
// connect to database + run query to grab all aircraft in database.
/*
include_once('dbconnection.php');
$str = "SELECT * FROM `aircraftsales`";
$rs = mysql_query($str);
if(!$rs )
{
die('Could not get data: ' . mysql_error());
}
if (mysql_num_rows($rs) == 0)
echo '<h4><font color="#909090">No current aircraft for sale.</font></h2>';
else {
while($row = mysql_fetch_assoc($rs)) {
*/
include_once('dbconnection.php');
$str="SELECT * FROM `aircraftsales`";
$rs = mysql_query($str);
if(!$rs )
{
die('Could not get data: ' . mysql_error());
}

$imagesstr="SELECT * FROM `aircraftimages`";
$imagesrs = mysql_query($imagesstr);
if(!$imagesrs )
{
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_assoc($rs)) {
?>
<div class="vehicle-blob list FORSALE">
<a href="/content.php?id=<?php echo $row['id']?>"><div class="vehicle-photo photo-list selected">
<img src="exam/upload/aircraftsales/<?php echo $imagerow['image'];?>" /></di
<div class="status-graphic"></div>
<div class="overlay list">
<div class="inner-tube">
<h1><?php echo $row['title']?> <?php echo $img;?> <br /><font color="#D60808"><b>&pound;<?php echo $row['price']?></b></font></h1>
</div>
</div>
</a>
<?php
}
?>
</div>
</div>
</div>
</div>


<?php include_once('ppls_css/includes/ppl-footer.php'); ?>

最佳答案

使用左连接查询。

SELECT * FROM aircraftsales left join aircraftimages on aircraftsales.aircraft_id = aircraftimages.aircraft_id

尝试一下

关于php - 显示来自两个表的信息 php?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33351250/

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