使用文件目录显示数据库中的图像

时间:2017-06-15 12:00:15

标签: php html css mysql

enter image description here我想将文件夹中的图像显示到网页上。图像目录已保存在数据库中。 MySQL查询是正确的。语法可以显示图像目录但无法显示图像。

<?php session_start(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head 
content must come *after* these tags -->
<title>Profile |CRB</title>

<!-- Bootstrap -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media 
queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js">
</script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js">
</script>
<![endif]-->
</head>


<body>
<?php include 'header.php' ?>
<ul class="nav nav-tabs">                  <!-- NAV TABS -->
<li role="presentation"><a href="index.php">Home</a></li>
<li role="presentation"><a href="trucks.php">Trucks</a></li>
<li role="presentation"><a href="suppliers.php">Suppliers</a></li>
<li role="presentation"><a href="clients.php">Clients</a></li>
<li role="presentation"><a href="services.php">Services</a></li>
<li role="presentation"><a href="accountspayables.php">Uploaded Files</a>
</li>
<li role="presentation"><a href="maintenance.php">Maintenance</a></li>
<!--  DROPDOWN start -->
<li role="presentation" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" 
aria-haspopup="true" aria-expanded="false">
  About us <span class="caret"></span>
</a>
<ul class="dropdown-menu">
  <li role="presentation"><a href="contactus.php">Contact us</a></li>
  <li role="presentation"><a href="aboutus.php">About us</a></li>
</ul>
</li>
<!-- END OF DROPDOWN --> 
<?php 
if(isset($_SESSION['started']) && $_SESSION['started']) {

}
?>

<li role="presentation" class="dropdown pull-right">
<a class="dropdown-toggle" data-toggle="dropdown" href="" role="button" 
aria-haspopup="true" aria-expanded="true">
  <span class="glyphicon glyphicon-user" style="cursor: pointer;" aria-
hidden="true"> <span class="caret"></span>
</a>
<ul class="dropdown-menu">
  <li role="presentation"><a href="">Settings</a></li>
  <li role="presentation"><a href="logout.php">Log out</a></li>
</ul>
</li>

<li class="pull-right" class="active"><a href="profile.php"><?php echo  
$_SESSION['user'];?></a></li>
</ul>
<!--  end of HEADER -->
<br>
<div class="row">
<div class="col-sm-4">

<?php include 'config.php'; 
if(isset($_SESSION['started']) && $_SESSION['started']) {

}
$val = '';  
$query="SELECT USER_PHOTOPATH FROM useraccounts WHERE USER_NAME = 
'".$_SESSION['user']."' ";
$stmt  = $conn->prepare($query); 
$stmt  -> bindParam(1,$val);
$stmt  -> execute();

$row   = $stmt->fetch(PDO::FETCH_ASSOC);
echo $row['USER_PHOTOPATH'];
?>

<img src="<?php echo $row['USER_PHOTOPATH']; ?>;">  <!-- I TRIED THIS SYNTAX 
TO DISPLAY THE IMAGE -->
</div>

<?php 

?>
<div class="col-sm-4">

<h1 class="text-primary">My Profile</h1>

<div class="col-sm-4"></div>
</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script 
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">
</script>
<!-- Include all compiled plugins (below), or include individual files as 
needed -->
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</script>
</html>

1 个答案:

答案 0 :(得分:0)

完成; php后请删除?> <img src="<?php echo $row['USER_PHOTOPATH']; ?>;">