简体   繁体   English

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

[英]Display image from database using file directory

在此处输入图片说明 I want to display the image from the folder to the webpage. 我想显示从文件夹到网页的图像。 The image directory is already saved on the database. 图像目录已保存在数据库中。 The MySQL query is correct. MySQL查询是正确的。 The syntax can display the image directory but cannot able to display the image. 该语法可以显示图像目录,但不能显示图像。

<?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>

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM