Home  >  Article  >  Backend Development  >  求指点,数据库图片输出分页

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

WBOY
WBOYOriginal
2016-06-13 12:23:10825browse

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


------解决思路----------------------
分页

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


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


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

参考: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