>数据库名称:项目
>表名:图片
> fields:id(int),file(varchar)[image url stored here],name(varchar)[image description]
PHP
$con=MysqL_connect("localhost","root","") or die("no connection ");
MysqL_select_db("project")or die("no database exit");
echo "MysqL_query("SELECT * FROM image");
echo "
MysqL_fetch_array($res)) {
echo "PHP echo $row["file"]; ?>" height="100px" width="150px"> PHP echo "
最佳答案
只需使用@geignerize description w3school php.net,此方法将检查图像是否确实存在.如果从db或目标中删除图像,则返回false.
$img="image url"; //orginal image url from db
if(!@getimagesize($img))
{
$img="default image" //if image not found this will display
}
?>
更新
为你的代码使用像这样
PHP
$con=MysqL_connect("localhost","") or die("no connection ");
MysqL_select_db("project")or die("no database exit");
echo "MysqL_query("SELECT * FROM image");
echo "
MysqL_fetch_array($res)) {
$img=$row["file"]; //orginal image url from db
if(!@getimagesize($img))
{
$img="default image" //if image not found this will display
}
echo "PHP echo $img; ?>" height="100px" width="150px"> PHP echo "
猜你在找的MySQL相关文章