我如何使用PHP從數據庫(基於用戶ID)獲取圖像url並將其顯示爲圖像。 http://mysite.com/img.php?id=338576php生成圖像?
下面的代碼顯示了一個php腳本進入數據庫,檢查特定用戶(使用上面鏈接中的id)是否存在,然後從該用戶的行中獲取圖像url。
<?php
//connect to database
include ("connect.php");
//Get the values
$id = mysql_real_escape_string($_GET['id']);
//get the image url
$result = mysql_query("SELECT * FROM users WHERE id='$id'")
or die(mysql_error());
$row = mysql_fetch_array($result);
if($row)
{
$img_url = row['imgurl'];
mysql_close($connect);
}
else{
}
?>
的$ Img_url是一個實際的圖像鏈接www.asite.com/image.jpg
問題是我如何使用PHP來進行從圖像鏈接($ img_url)的圖像?其中http://mysite.com/img.php?id=338576
將變成圖像。
我希望有人能指導我
謝謝!
退房這個問題。我認爲它與你非常相似:http://stackoverflow.com/questions/1431875/how-do-i-script-a-php-file-to-display-an-image-like-img-src-img -phpimageid-3 –