[PHP与MySQL]①①--前台部分 列表显示

Paste_Image.png
Paste_Image.png

article.list.php

<?php 
    require_once('connect.php');
    $sql = "select * from article order by dateline desc";
    $query = mysql_query($sql);
    if($query&&mysql_num_rows($query)){
        while($row = mysql_fetch_assoc($query)){
            $data[] = $row;
        }
    }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>文章发布系统</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<!-- start header -->
<div id="header">
    <div id="logo">
        <h1><a href="#">php与mysql<sup></sup></a></h1>
        <h2></h2>
    </div>
    <div id="menu">
        <ul>
            <li class="active"><a href="article.list.php">文章</a></li>
            <li><a href="about.php">关于我们</a></li>
            <li><a href="contact.php">联系我们</a></li>
        </ul>
    </div>
</div>
<!-- end header -->
</div>

<!-- start page -->
<div id="page">
    <!-- start content -->
    <div id="content">
    <?php
        if(empty($data)){   
            echo "当前没有文章,请管理员在后台添加文章";
        }else{
            foreach($data as $value){
    ?>
        <div class="post">
            <h1 class="title"><?php echo $value['title']?><span style="color:#ccc;font-size:14px;">  作者:<!--作者放置到这里--><?php echo $value['author']?></span></h1>
            <div class="entry">
                <?php echo $value['description']?>
            </div>
            <div class="meta">
                <p class="links"><a href="article.show.php?id=<?php echo $value['id']?>" class="more">查看详细</a>  »  </p>
            </div>
        </div>
    <?php
            }
        }
    ?>
    </div>
    <!-- end content -->
    <!-- start sidebar -->
    <div id="sidebar">
        <ul>
            <li id="search">
                <h2><b class="text1">Search</b></h2>
                <form method="get" action="article.search.php">
                    <fieldset>
                    <input type="text" id="s" name="key" value="" />
                    <input type="submit" id="x" value="Search" />
                    </fieldset>
                </form>
            </li>
        </ul>
    </div>
    <!-- end sidebar -->
    <div style="clear: both;"> </div>
</div>
<!-- end page -->
<!-- start footer -->
<div id="footer">
    <p id="legal"></p>
</div>
<!-- end footer -->
</body>
</html>

default.css

/*
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
*/

body {
    margin: 0;
    padding: 0;
    background: #FFFFFF;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    color: #6D6D6D;
}

h1, h2, h3 {
    margin: 0;
    text-transform: lowercase;
    font-weight: normal;
    color: #78CC00;
}

h1 {
    letter-spacing: -1px;
    font-size: 32px;
}

h2 {
    font-size: 23px;
}

p, ul, ol {
    margin: 0 0 2em 0;
    text-align: justify;
    line-height: 26px;
}

a:link {
    color: #7AD000;
}

a:hover, a:active {
    text-decoration: none;
    color: #7AD000;
}

a:visited {
    color: #7AD000;
}

img {
    border: none;
}

img.left {
    float: left;
    margin: 7px 15px 0 0;
}

img.right {
    float: right;
    margin: 7px 0 0 15px;
}

/* Form */

form {
    margin: 0;
    padding: 0;
}

fieldset {
    margin: 0;
    padding: 0;
    border: none;
}

legend {
    display: none;
}

input, textarea, select {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 13px;
    color: #333333;
}

#wrapper {
    background: #7ACF00 url(images/img03.jpg);
}

/* Header */

#header {
    width: 900px;
    height: 80px;
    margin: 0 auto 20px auto;
    padding-top: 10px;
}

#logo {
    float: left;
    height: 120px;
    margin-left: 30px;
}

#logo h1 {
    font-size: 38px;
    color: #3399CC;
}

#logo h1 sup {
    vertical-align: text-top;
    font-size: 24px;
}

#logo h1 a {
    color: #FFFFFF;
}

#logo h2 {
    text-transform: uppercase;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    color: #FFFFFF;
}

#logo a {
    text-decoration: none;
    color: #FFFFFF;
}

/* Menu */

#menu {
    float: right;
}

#menu ul {
    margin: 0;
    padding: 28px 0 0 0;
    list-style: none;
}

#menu li {
    display: inline;
}

#menu a {
    display: block;
    float: left;
    margin-left: 5px;
    background: #6AB000;
    padding: 7px 10px;
    text-decoration: none;
    font-size: 15px;
    color: #FFFFFF;
}

#menu a:hover {
    text-decoration: underline;
}

#menu .active a {
}

/* Page */

#page {
    width: 900px;
    margin: 0 auto;
    padding: 20px 20px;
}

/* Content */

#content {
    float: left;
    width: 590px;
    padding: 0px 30px 0px 30px;
}

/* Post */

.post {
}

.post .title {
    margin-bottom: 20px;
    padding-bottom: 5px;
    border-bottom: 10px solid #EDEDED;
}

.post .entry {
}

.post .meta {
    margin: 0;
    padding: 0 0 60px 0;
    background: url(images/img04.jpg) repeat-x left 30%;
}

.post .meta p {
    margin: 0;
    line-height: normal;
}

.post .meta .byline {
    float: left;
    color: #0000FF;
}

.post .meta .links {
    float: left;
}

.post .meta .more {
    width: 185px;
    height: 35px;
    padding: 5px 0px 5px 0px;
    text-transform: uppercase;
    text-decoration: none;
    font-size: 11px;
}

.post .meta .comments {
    padding: 5px 0px 5px 0px;
    text-transform: uppercase;
    text-decoration: none;
    font-size: 11px;
}

.post .meta b {
    display: none;
}

/* Sidebar */

#sidebar {
    float: right;
    width: 230px;
}

#sidebar ul {
    margin: 0;
    padding: 10px 0 0 0;
    list-style: none;
}

#sidebar li {
    margin-bottom: 40px;
}

#sidebar li ul {
}

#sidebar li li {
    margin: 0;
    padding: 3px 0;
    border-bottom: 1px dashed #D1D1D1;
}

#sidebar li li a {
    margin: 0;
    padding-left: 25px;
    background: url(images/img01.png) no-repeat left 50%;
}

#sidebar h2 {
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 10px solid #EDEDED;
    font-size: 18px;
    font-weight: normal;
}

#sidebar a {
    text-decoration: none;
    color: #6D6D6D;
}

/* Search */

#search {
}

#search h2 {
    margin-bottom: 20px;
}

#s {
    width: 150px;
    margin-right: 5px;
    padding: 3px;
    border: 1px solid #F0F0F0;
}

#x {
    padding: 3px;
    background: #ECECEC url(images/img08.gif) repeat-x left bottom;
    border: none;
    text-transform: lowercase;
    font-size: 11px;
    color: #4F4F4F;
}

/* Boxes */

.box1 {
    padding: 20px;
    background: url(images/img05.gif) no-repeat;
}

.box2 {
    color: #BABABA;
}

.box2 h2 {
    margin-bottom: 15px;
    background: url(images/img10.gif) repeat-x left bottom;
    font-size: 16px;
    color: #FFFFFF;
}

.box2 ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.box2 a:link, .box2 a:hover, .box2 a:active, .box2 a:visited  {
    color: #EDEDED;
}

/* Footer */

#footer {
    height: 400px;
    min-height: 74px;
    padding: 10px 0 0 0;
    background: #979797 url(images/img02.jpg) repeat-x left top;
    font-family: Tahoma, Arial, Helvetica, sans-serif;
}

html>body #footer {
    height: auto;
}

#legal {
    clear: both;
    padding-top: 20px;
    text-align: center;
    text-transform: uppercase;
    font-size: 10px;
    color: #353535;
}

#legal a {
    font-weight: bold;
    color: #FFFFFF;
}

Paste_Image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 199,902评论 5 468
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,037评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 146,978评论 0 332
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,867评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,763评论 5 360
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,104评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,565评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,236评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,379评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,313评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,363评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,034评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,637评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,719评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,952评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,371评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 41,948评论 2 341

推荐阅读更多精彩内容