Home > Article > Backend Development > 求指点,数据库图片输出分页
求指导,数据库图片输出分页
我已经把图片存到数据了,现在想分页的输出在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 />