PHP中的HTML样式不遵循CSS

时间:2013-11-15 13:50:54

标签: php html css

我有一些带有HTML输出的PHP脚本,我希望使用CSS文件设置样式。我已经放置了正确的div和span类,理论上应该从CSS文件和样式正确调用。只有他们似乎没有,我无法理解为什么。

文本样式看起来不错但是它的填充物搞砸了。我已粘贴以下代码:

<?php
// How Many Topics you want to display?
$topicnumber = 5;
// Change this to your phpBB path
$urlPath = "/forum";

// Database Configuration (Where your phpBB config.php file is located)
include 'forum/config.php';

$table_topics = $table_prefix. "topics";
$table_forums = $table_prefix. "forums";
$table_posts = $table_prefix. "posts";
$table_users = $table_prefix. "users";
$link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("Could not connect");
mysql_select_db("$dbname") or die("Could not select database");

$query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
WHERE t.topic_id = p.topic_id AND
f.forum_id = t.forum_id AND
t.forum_id != 4 AND
t.topic_status <> 2 AND
p.post_id = t.topic_last_post_id AND
p.poster_id = u.user_id
ORDER BY p.post_id DESC LIMIT $topicnumber";
$result = mysql_query($query) or die("Query failed");                                   

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

echo  "<article><figure><img src='voxis-template/HTML & CSS/img/gaming12.jpg' alt='' /></figure><div class='text'><h3><a href=\"$urlPath/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]&p=$row[post_id]#p$row[post_id]\" TARGET=\"_blank\"></h3></div>" .
$row["topic_title"] .
"<span class='info'></a></td></font></b><td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#C0C0C0\"> by: <a href=\"$urlPath/memberlist.php?mode=viewprofile&u=$row[user_id]\" TARGET=\"_blank\"></span>" .
$row["username"] .
"</td><td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#C0C0C0\">" .
date('F j, Y, g:i a', $row["post_time"]) .
"</td></tr></font></article>";
}

mysql_free_result($result);
mysql_close($link);
?>

以下是其包装Divs中的相同代码

<div class='span4 article-box'>
                    <div class='box-title'>
                        <h2>Forum Posts </h2>
                        <div class='title-line'></div>
                    </div>
                    <article class='first-child'>
                        <figure>
                            <img src="voxis-template/HTML & CSS/img/gaming01.jpg" alt="" />
                        </figure>
                        <div class='text'>
                            <h3><a href="forum/viewtopic.php?f=17&t=8">Improve your landings with our ILS Training tips posted on the forum. Get your landings under 200fpm!</a></h3>
                            <span class='info'>Mon Jan 07, 2013 11:05 pm</span>
                        </div>
                    </article>
                    <article>
                        <figure>
                            <img src="voxis-template/HTML & CSS/img/gaming02.jpg" alt="" />
                        </figure>
                        <div class='text'>
                            <h3><a href="forum/viewtopic.php?f=2&t=92">ORBX Global Scenery is out! See the world in stunning photorealism. </a></h3>
                            <span class='info'>Sat Jul 27, 2013 3:38 am</span>
                        </div>
                    </article>
                    <article>
                        <figure>
                            <img src="voxis-template/HTML & CSS/img/gaming03.jpg" alt="" />
                        </figure>
                        <div class='text'>
                            <h3><a href="forum/viewtopic.php?f=7&t=74">Pilots take to the skies in an "around the world" flight.</a></h3>
                            <span class='info'>Tue Jun 18, 2013 10:38 am</span>
                        </div>
                    </article>
                    <article>
                        <figure>
                            <img src="voxis-template/HTML & CSS/img/gaming07.jpg" alt="" />
                        </figure>
                        <div class='text'>
                            <h3><a href="forum/viewtopic.php?f=10&t=75">Can you add a UK/Europe route please...</a></h3>
                            <span class='info'>Tue Jun 18, 2013 10:40 am</span>
                        </div>
                    </article>
                    <article>
                        <figure>
                            <img src="voxis-template/HTML & CSS/img/gaming08.jpg" alt="" />
                        </figure>
                        <div class='text'>
                            <h3><a href="forum/viewtopic.php?f=11&t=53">Please read the rules of the airline. They are designed to keep everything happy and harmonious...</a></h3>
                            <span class='info'>Wed Mar 06, 2013 9:46 am</span>
                        </div>
                    </article>
                    <article>
                        <figure>
                            <img src="voxis-template/HTML & CSS/img/gaming09.jpg" alt="" />
                        </figure>
                        <div class='text'>
                            <h3><a href="forum/viewtopic.php?f=2&t=94">New USA Hub announced at John F Kennedy International.</a></h3>
                            <span class='info'> Sat Aug 17, 2013 3:54 pm</span>
                        </div>
                    </article>
                    <article>
                        <figure>
                            <img src="voxis-template/HTML & CSS/img/gaming10.jpg" alt="" />
                        </figure>
                        <div class='text'>
                            <h3><a href="voxis-template/HTML & CSS/blog.html">Thoughts on changing flight management system. VAFS, FS Airlines or PHPVMS...</a></h3>
                            <span class='info'>Wed Jul 03, 2013 11:06 am</span>
                        </div>
                    </article>
                    <article>
                        <figure>
                            <img src="voxis-template/HTML & CSS/img/gaming11.jpg" alt="" />
                        </figure>
                        <div class='text'>
                            <h3><a href="forum/viewtopic.php?f=19&t=27">Blue Spirit's FS Open Session proves popular. We're up to 6th place in the rankings...</a></h3>
                            <span class='info'>Thu Jan 17, 2013 10:53 pm</span>
                        </div>
                    </article>
                    <article>
                        <figure>
                            <img src="voxis-template/HTML & CSS/img/gaming12.jpg" alt="" />
                        </figure>
                        <div class='text'>
                            <h3><a href="forum/viewtopic.php?f=23&t=67">New CRJ700 added to the fleet.</a></h3>
                            <span class='info'>Wed Jun 05, 2013 10:57 am</span>
                        </div>
                    </article>
                        <?php
// How Many Topics you want to display?
$topicnumber = 5;
// Change this to your phpBB path
$urlPath = "/forum";

// Database Configuration (Where your phpBB config.php file is located)
include 'forum/config.php';

$table_topics = $table_prefix. "topics";
$table_forums = $table_prefix. "forums";
$table_posts = $table_prefix. "posts";
$table_users = $table_prefix. "users";
$link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("Could not connect");
mysql_select_db("$dbname") or die("Could not select database");

$query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
WHERE t.topic_id = p.topic_id AND
f.forum_id = t.forum_id AND
t.forum_id != 4 AND
t.topic_status <> 2 AND
p.post_id = t.topic_last_post_id AND
p.poster_id = u.user_id
ORDER BY p.post_id DESC LIMIT $topicnumber";
$result = mysql_query($query) or die("Query failed");                                   

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

echo  "<article><figure><img src='voxis-template/HTML & CSS/img/gaming12.jpg' alt='' /></figure><div class='text'><h3><a href=\"$urlPath/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]&p=$row[post_id]#p$row[post_id]\" TARGET=\"_blank\"></h3></div>" .
$row["topic_title"] .
"<span class='info'></a></td></font></b><td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#C0C0C0\"> by: <a href=\"$urlPath/memberlist.php?mode=viewprofile&u=$row[user_id]\" TARGET=\"_blank\"></span>" .
$row["username"] .
"</td><td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#C0C0C0\">" .
date('F j, Y, g:i a', $row["post_time"]) .
"</td></tr></font></article>";
}

mysql_free_result($result);
mysql_close($link);
?>

                </div>

您可以看到实时示例here。如果你向下看页面的左侧,你会看到一些静态帖子,然后是列表底部的php。如果你看图像,你会看到我对填充或边距的意思。

我无法弄清楚什么是错的,我希望其他人可以。看来CSS没有被正确引用或引用?

由于

安迪

1 个答案:

答案 0 :(得分:0)

您可能希望将结束</a>代码移至结束</h3>

之前

然后,您可以删除整个代码中的随机<td></td>

这可能有所帮助。

PS:我还看到一个结束</b>代码,但没有<b>代码。