php综合练习--mymessbox--user相册
<?php $conn = mysql_connect("localhost", "root", "111"); mysql_select_db("mymessbox", $conn); mysql_query("set names utf8"); $totsql = "select count(*) from photo"; $totret = mysql_query($totsql); $totrow = mysql_fetch_row($totret); $length = 8; $totnum = ceil($totrow[0] / $length); $pagenum = @$_GET[‘page‘] ? $_GET[‘page‘] : 1; if ($pagenum > $totnum) { $pagenum = $totnum; } $offset = ($pagenum - 1 ) * $length; $sql1 = "select * from photo order by id desc limit {$offset},{$length}"; $ret1 = mysql_query($sql1); ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>photo</title> <style> body { margin:0px; padding:0px; font-family: ‘宋体‘, Simsun; } h2 { margin: 0px; padding: 0px; } a { text-decoration: none; font-size: 18px; font-weight: bold; } a:hover { position: relative; top: 1px; left: 1px; } #wrap { width: 700px; margin: 0 auto; } #header { width: 100%; height: 60px; background: #ccc; font-size: 30px; font-family: Comic Sans MS; line-height: 60px; text-align: center; } .nav { margin: 0 auto; width: 100%; height: 5px; clear:both; } #menu { width: 100%; height: 30px; background: #ccc; line-height: 30px; } .mu { width: 50px; padding-left: 104px; } #content { width: 100%; margin: 0 auto; background: #ccc; } .image { width: 200px; float :left; margin-left: 30px; } .imgname { width: 100%; text-align: center; font-family: Courier, "Courier New", monospace; font-weight: bold; } #page { width: 100%; text-align: center; clear: both; padding-top: 10px; } #footer { width: 100%; height: 50px; background: #ccc; line-height: 50px; text-align: center; } #footer a{ font-size: 10px; font-weight: bold; } </style> </head> <body> <div id="wrap"> <div id="header">My Zone</div> <div class="nav"></div> <div id="menu"> <span class="mu"> <a href=‘index.php‘>主页</a> </span> <span class="mu"> <a href=‘‘>相册</a> </span> <span class="mu"> <a href=‘say.php‘>说说</a> </span> <span class="mu"> <a href=‘mess.php‘>留言</a> </span> </div> <div class="nav"></div> <div id="content"> <?php while ($row1 = mysql_fetch_assoc($ret1)) { ?> <div class="image"> <img src="../manager/fileupload/<?php echo $row1[‘dstfile‘] ?>" width="200px" height="200px"> <div class="imgname"><?php echo $row1[‘file‘] ?></div> <!-- debug 点击变大图 --> </div> <?php } $prevpage = $pagenum - 1; $nextpage = $pagenum + 1; echo " <div id=‘page‘> <a href=‘photo.php?page=$prevpage‘>上一页</a>|<a href=‘photo.php?page=$nextpage‘>下一页</a> </div>"; ?> </div> <div class="nav"></div> <div id="footer"> <a href="http://www.baidu.com">百度一下</a>|<a href="https://www.google.com/hk">google</a> </div> </div> </body> </html>
还有很多功能没有完善,比如说,点击图片,出现大图。
先将这个体系建立起来,然后再完善。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。