2017-11-22 25 views
0

明らかに私は画像の表示に問題があります。なぜなら、ファイルの名前が表示されているだけなので、すぐにウェブページに表示されるのですか?以下 は、画像と私はそれがで表示したい場所を保持している私のデータベースの2screenshotsと一緒に私のソースコードです:データベースから直接画像を表示

<?php 

error_reporting(E_ERROR); 

include("global.php"); 


session_start(); 

$receipt = $_GET['receipt']; 
$userid = $_SESSION ['userid']; 
if (isset($_SESSION['userid']) == false) 
{ 
    header ("Location: login.php"); 
} 

$mysqli = new mysqli(spf, dbuser, dbpw, db); 
$stmt = $mysqli->prepare("SELECT receipt, date, time, pick, dropoff, userid, carno, cost, branch, area, image FROM items where receipt=?"); 
$stmt->bind_param("s", $receipt); 
$stmt->execute(); 
$stmt->bind_result($receipt, $date, $time, $pick, $dropoff, $userid, $carno, $cost, $branch, $area, $image); 

while ($stmt->fetch()) { 
    echo "<table border='1' style='width:40%'>"; 
    echo "<td>"; 
    echo "<b>Receipt ID: $receipt</b>"; 
    echo "<br><br>"; 
    echo "$image"; 
    echo "<br><br>"; 
    echo "<b>Date of Travel: $date</b>"; 
    echo "<br><br>"; 
    echo "<b>Time of Travel: $time</b>"; 
    echo "<br><br>"; 
    echo "<b>Pick Up Location: $pick</b>"; 
    echo "<br><br>"; 
    echo "<b>Drop Off Location: $dropoff</b>"; 
    echo "<br><br>"; 
    echo "<b>Area of DropOff: $area</b>"; 
    echo "<br><br>"; 
    echo "<b>Cost of Trip: $cost</b>"; 
    echo "<br><br>"; 
    echo "<b>User ID (NRIC): $userid</b>"; 
    echo "<br><br>"; 
    echo "<b>Branch of Officer: $branch</b>"; 
    echo "</td>"; 
} 

echo "</table>"; 

$stmt->close(); 
$mysqli->close(); 

?> 

プレビュー: location where i want to display my image

An image file name inside the database

+2

以下のように使用<img>タグがタグを使用します。エコー ""; –

+0

答えを書く@romanreign!それは他の人がそれを見るのがより簡単になります(これは正解です)。 –

+0

@romanreignすごくうれしいです:) –

答えて

3

echo "<img src=$image>" 
0

これを試してみてください。

echo "<img src='$image'>"; 

詳細については、img

関連する問題