douyeke2695 2016-07-25 20:30
浏览 93
已采纳

echo无法正常工作

Echo works fine at other lines But when i try to add tag to this table, i see that tags placed out of the tag.

    <table>
<th style="cursor:pointer;border-radius:5px 0px 0px 0px;">Başlık</th>
<th style="cursor:pointer;">Başlatan</th>
<th style="cursor:pointer;border-radius:0px 5px 0px 0px;">Tarih</th>

$sonuc = mysql_query("select A.subject, A.poster_name, A.poster_time, A.id_msg, A.id_topic, B.id_first_msg, B.id_member_started from smf_messages A, smf_topics B WHERE A.id_msg = B.id_first_msg ORDER BY id_topic DESC LIMIT 10");

if(mysql_num_rows($sonuc)!=0)
{
    while($oku = mysql_fetch_object($sonuc))
    {
        echo '<tr id="iceriktablo" style="cursor:pointer;margin-top:0;margin-bottom:0;">';
        echo '<a href="forum/index.php?topic='. $oku->id_topic .'"><td style="font-size:13px;font-weight:bold;">';
        echo $oku->subject;
        echo '</td></a>';
        echo '<a href="forum/index.php?topic='. $oku->id_topic .'"><td style="font-size:13px;font-weight:bold;"><center><b>';
        echo $oku->poster_name;
        echo '</b></center></td></a>';
        echo '<td style="font-size:13px;font-weight:bold;"><center><b>';
        $zaman = $oku->poster_time;
        echo gmdate("d-m-Y\ H:i:s", $zaman);
        echo '</b></center></td></tr></a>';
    }
}else{
    echo "Hiçbir kayıt bulunamadı!";
}
mysql_close($conn);
?>

</table>

result as inspect element: http://puu.sh/qed4c/7b04611347.png result: enter image description here filename: index.php

  • 写回答

2条回答 默认 最新

  • dongpu1331 2016-07-25 20:42
    关注

    Your HTML is invalid:

        echo '<a href="forum/index.php?topic='. $oku->id_topic .'"><td style="font-size:13px;font-weight:bold;"><center><b>';
        echo $oku->poster_name;
        echo '</b></center></td></a>';
    

    The A-tag isn't allowed to wrap TD (and of course some more). I guess the browser corrected that automatically.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?