我最近开始学习Javascript,但仍然没有在这个问题上的专家。
所以我想知道是否有人云帮助我。如何在php无法从服务器提取图像时显示图像?
我使用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>";
你把blank.jpg图像放在图像文件夹? – 2011-06-03 05:28:43