2013-11-15 2 views
0

У меня есть немного PHP-скрипта с выходом эха в HTML, который я хочу использовать, используя CSS-файл. Я разместил правильные классы div и span, которые теоретически должны вызвать из файла CSS и стиля правильно. Только они не кажутся, и я не могу понять, почему.HTML Укладка внутри PHP не соответствует 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); 
?> 

Ниже приведен тот же код в обертке дивов

<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 не тянет или не ссылается должным образом?

Благодаря

Энди

+3

Посмотрите на свои ссылки, в статике они находятся внутри h3, в php они находятся после h3 (также с пустым внутри h3). используйте инспектор элементов в хром или firebug, будет легче увидеть проблемы с «prettified» html –

+1

Если вы потрудились посмотреть на ваш обработанный источник, вы увидите, где вы ошибетесь. Почему вы добавляете встроенный css, когда вам нужно придерживаться своих классов. –

+1

также есть теги таблицы (', ') в вашем сгенерированном содержимом, которых нет в вашем статическом содержимом – cypherabe

ответ

0

Вы можете переместить закрытия </a> тег перед закрытием </h3>

Затем вы можете удалить случайные <td> и </td> по всему коду.

Это может помочь.

PS: Я также вижу закрывающий тег </b>, но не <b> тег.

Смежные вопросы