Sezer Toker
Sezer Toker

Reputation: 21

echo doesn't work correctly

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

Upvotes: 0

Views: 121

Answers (2)

zajonc
zajonc

Reputation: 1969

Tag A is not a part of a table to it will be always placed out of it. You can't do somethig like this

<table>
    <tr>
        <a><td></td></a>
    </tr>
</table>

You should place your A tag inside TD or TH tag.

Upvotes: 0

Honk der Hase
Honk der Hase

Reputation: 2488

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.

Upvotes: 1

Related Questions