gpt4 book ai didi

php - 使用 phpmyadmin 中的 php 显示产品项目无法正常工作的图像

转载 作者:行者123 更新时间:2023-11-29 18:35:08 34 4
gpt4 key购买 nike

我正在 mysql phpmyadmin 中放置我的图书项目的链接。所有图像都存储在 htdocs 的 img 文件夹中。我似乎无法显示这些图像。

/我首先从数据库中读取书籍信息

<?php

include ("db_con.php");


//read all books
$book_query= "select * from book";

$run_query=mysqli_query($dbcon, $book_query);

$isbn=array();
$author=array();
$book=array();
$page=array();
$weight=array();
$publisher=array();
$edition=array();
$language=array();
$img=array();



if(mysqli_num_rows($run_query)>0)
{


while( $row = mysqli_fetch_assoc( $run_query)){

array_push($isbn,$row['isbn']);
array_push($author,$row['author']);
array_push($book,$row['book']);
array_push($page,$row['page']);
array_push($weight,$row['weight']);
array_push($publisher,$row['publisher']);
array_push($edition,$row['edition']);
array_push($language,$row['language']);
array_push($img,$row['img']);


}
//echo "$img[0]";
//print_r($img);

}


mysqli_close($dbcon);


?>

然后我尝试显示它

<?php include ("local_book_db.php"); ?>
<section id="recommended">
<p id="typeNew">Recommended</p>

<a href=""><img src="$img[0]" alt="aaa">a book</a>



</section>

它只显示替代字符串而不显示图像如何显示图像?

谢谢

最佳答案

您需要“回显”图像 url,我假设该图像位于 $img 数组中。

正确的代码是:

 <a href=""><img src="<?php echo $img[0]; ?>" alt="aaa">a book</a>

希望这有帮助!仅当 $img 是数组并且 $img[0] 保存图像 url 时,此代码才有效。

关于php - 使用 phpmyadmin 中的 php 显示产品项目无法正常工作的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45375042/

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