按名称显示数据库中的图像 [英] display image from database by name

查看:56
本文介绍了按名称显示数据库中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有数据库

`image_name`, `caption`, `image`, `username`

我想在数据库中按照他的名字显示图像(image_name)我有这个代码错误,图像没有显示



I want to display the image according his name in database(image_name)I have this code the error in it the image is not show

<?php

 require_once("db.php");
 session_start();
 $username = $_SESSION['username'];
 $sql = "SELECT * from photo2 WHERE Username='$username'";
 $result = mysql_query($sql) or die (mysql_error());
 $numrows = mysql_num_rows ($result);
 if($numrows!=0)
   {
  while ($found_ids = mysql_fetch_assoc($result))
  {

  echo "<tr><td align='center'> $found_ids[image_name]</a></td>  </tr>";
      //echo "<img src=get.php?id=$found_ids[ID]";
   }
}

$id = addslashes($_REQUEST['image_name']);
$image = mysql_query("SELECT * FROM photo2 WHERE image_name=$id");
$image = mysql_fetch_assoc($image);
$image = $image['Photodata'];

header ("Content-type: image/jpeg");
echo $image;

?>

推荐答案

username =
username =


_SESSION [' username'< /跨度>];
_SESSION['username'];


sql = SELECT * from photo2 WHERE Username ='
sql = "SELECT * from photo2 WHERE Username='


这篇关于按名称显示数据库中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆