Home >Backend Development >PHP Tutorial >求指导,数据库图片输出分页

求指导,数据库图片输出分页

WBOY
WBOYOriginal
2016-06-23 13:30:29936browse

我已经把图片存到数据了,现在想分页的输出在html页面上,每页显示3张
数据库表是
能不能告诉我具体代码啊,谢谢!


回复讨论(解决方案)

分页

$sqlstr = "select count(*) as recount from photo";$query = mysql_query($sqlstr) or die(mysql_error());$result = mysql_fetch_assoc($query);$recount = $result['recount'];$pagesize = 3;$page = isset($_GET['page'])? $_GET['page'] : 1;$offset = ($page-1)*$pagesize;$sqlstr = "select * from photo limit $offset, $pagesize";$query = mysql_query($sqlstr) or die(mysql_error());while($thread=mysql_fetch_assoc($query)){	echo '<img  src="show.php?id='.$thread['id'].'" alt="求指导,数据库图片输出分页" >';}


显示图片
$id = isset($_GET['id'])? $_GET['id'] : 0;$sqlstr = "select * from photo where id='".$id."'";$query = mysql_query($sqlstr) or die(mysql_error());$result = mysql_fetch_assoc($query);if($result){	header('content-type:'.$result['type']);	echo $result['binarydata'];}


连接数据库你自己加上就可以了。

参考: http://blog.csdn.net/fdipzone/article/details/39915131

谢谢!感激涕零啊,有些东西初学者琢磨半天也可能搞不明白,还是需要多问问好

谢谢!感激涕零啊,有些东西初学者琢磨半天也可能搞不明白,还是需要多问问好



如问题已解决请结贴。


谢谢!感激涕零啊,有些东西初学者琢磨半天也可能搞不明白,还是需要多问问好



如问题已解决请结贴。 谢谢,没搞清这个论坛规则,麻烦了
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn