我最近开始学习 Javascript,但仍然不是该主题的专家。
所以我想知道是否有人云帮助我。
我正在使用 MySql 数据库和 PHP 构建一个投资组合网站
我的数据库表有 3 个冒号:name, small_image, description
.
我已经设置了我的 PHP,以便它提取name
和small_image
.
$name = htmlentities( $row['name'] );
$image_small = "images/" . $row['image_small'];
它像这样回响:
$name
< img src='$image_small' with='$width' height='$height' />
我唯一的问题是,当我进入管理页面并在网站上添加一个没有图像的新作品时,它会出现一个空白区域。
我想做的是有一个可以替换丢失图像的图像?
有没有办法让它工作?还是更好、更简单的方法?
对此,我真的非常感激 。
不在这里工作的是完整的代码。
< - - - - - - - - - - - - - - - - - - - 完整代码 - - - - - - - - - - - - - - >
// Loop through all of the records returned from the query
while( $row = mysql_fetch_array( $results ) ) {
// collect data from each field
$id = $row['id'];
$name = htmlentities( $row['name'] );
$desc_short = htmlentities( $row['desc_short'] );
if(isset( $row['image_small'])){
$image_small = "images/jewelry/small/" . $row['image_small'];
}
else{
$image_small = "images/blank.jpg";
}
echo "
<li class='column_$x $last_row_class'>
<a href='details.php?id=$id'>
<img src='$image_small' with='$width' height='$height' />
</a>
<p class='product_name'><a href='details.php?id=$id'>$name</a></p>
<p class='product_desc'>$desc_short</p>
$rating_div
</li>";