请问怎样把MYSQL数据库里的图片整个读取输出到table里显示出来?
来源:百度知道 编辑:UC知道 时间:2024/06/17 15:35:02
我的问题是:
我把图片上传到 我的 mysql 数据库 用 longblob 格式储存, 我不知道怎么用php 显示
我的数据库结构如下:
ID (int, autoincrease PK) //PK for the table
Name (varchar(255)) //image name
Data (longblob) // store the image binary data
我想用PHP 把整个的表的内容在 table 里 输出出来
我把图片上传到 我的 mysql 数据库 用 longblob 格式储存, 我不知道怎么用php 显示
我的数据库结构如下:
ID (int, autoincrease PK) //PK for the table
Name (varchar(255)) //image name
Data (longblob) // store the image binary data
我想用PHP 把整个的表的内容在 table 里 输出出来
用while循环输出
<?
//连接MYSQL
mysql_connect("localhost","username","password");
//选择数据库
mysql_select_db("tablename");
//sql语句
$sql=mysql_query("select * from tablename;");
echo "<table>\r";
echo "<tr><td>ID</td><td>NAME</td><td>DATA</td></tr>\r";
//循环输出所有内容到表格里mysql_fetch_array()是将结果存为数组
while($res=mysql_fetch_array($sql)){
echo "<tr><td>".$res["ID"]."</td><td>".$res["Name"]."</td><td>".$res["Data"]."</td></tr>\r";
}
echo "</table>\r";
?>