<?php $conn = MySQL_connect("localhost", "root", "111"); mysql_select_db("mymessbox", $conn); mysql_query("set names utf8"); function sub_title($title){ $len = 22; return mb_strlen($title, 'utf-8')<=$len ? $title : (mb_substr($title,0,$len,'utf-8')."..."); } ?><!doctype html><html lang="en"><head> <meta charset="UTF-8"> <title>myMessBox</title> <style> body { margin:0px; padding:0px; font-family: '宋体', Simsun; } a { text-decoration: none; font-size: 18px; font-weight: bold; padding-left: 105px; } 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; } #content { width: 100%; margin: 0 auto; } #left { float: left; width: 200px; height: 790px; background: #ccc; } .am { width: 100%; height: 16px; line-height: 24px; font-size: 16px; font-weight: bold; font-family: Comic Sans MS; margin-left: 7px; } #myphoto { margin-top: 7px; margin-left: 7px; } #right { float: right; width: 494px; height: 790px; background: #ccc; margin-left: 5px; float: right; } #photo { width: 100%; height: 370px; } .more{ padding-left: 280px; } .more a { font-size: 14px; } .image { width: 200px; float :left; margin-left: 30px; } .imgname { width: 100%; text-align: center; font-family: Courier, "Courier New", monospace; font-weight: bold; } .say { width:100%; margin: 15px auto; font-family: "宋体",Simsun; font-weight: bold; } #title { margin-left: 25px; } #title a { text-decoration: none; font-size: 18px; font-weight: bold; padding-left: 0px; } #title a:visited { color: red; } #footer { width: 100%; height: 50px; background: #ccc; line-height: 50px; text-align: center; } #footer a{ text-decoration: none; font-size: 18px; font-weight: bold; padding-left: 0px; } </style></head><body> <div id="wrap"> <div id="header">My Zone</div> <div class="nav"></div> <div id="menu"><a href='no'>主页</a><a href='photo.php'>相册</a><a href='say.php'>说说</a><a href='mess.php'>留言</a></div> <div class="nav"></div> <div id="content"> <div id="left"> <div class="am"> About me: </div> <hr> <span class="am"> Name: </span> <span id="name">solverpeng</span> <br> <span class="am"> Age: </span> <span id="age">twenty-three</span> <br> <span class="am"> MyPhoto: </span> <div id="myphoto"> <img src="myphoto.jpg" alt="myphoto"> </div> <hr> </div> <div id="right"> <div id="photo"> <div class="am"> <span> Photo: </span> <span class="more"> <a href='photo.php'>more</a> </span> </div> <hr> <?php $sql = "select dstfile,file from photo order by id desc limit 4"; $rst = mysql_query($sql); while ($arr = mysql_fetch_assoc($rst)) { ?> <div class="image"> <img src="../manager/fileupload/<?php echo $arr['dstfile'] ?>" alt="<?php echo $arr['file'] ?>" width="150px" height="150px"> <div class="imgname"><?php echo $arr['file'] ?></div> <!-- debug 点击变大图 --> </div> <?php } ?> </div> <hr> <div id="say"> <div class="am"> <span > Say: </span> <span class="more"> <a href='say.php'>more</a> </span> </div> <hr> <?php $sql2 = "select id,title from say order by id desc limit 10"; $rst2 = mysql_query($sql2); while ($arr2 = mysql_fetch_assoc($rst2)) { ?> <div class="say"> <span id="title"><a href="content.php?id=<?php echo $arr2['id']?>"><?php echo sub_title($arr2['title']);?></a></span> </div> <?php } ?> </div> </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>index.php
还有很多没有完善的地方,还有许多不合理的地方,但是我会一步一步的完善,页面,逻辑,功能。