2012-11-12 89 views
2

我寫的這段代碼顯示了3個表和表名的組合。如果每次只顯示一個標題,則當標題顯示在表格上方時,但是當顯示全部三個標題時,標籤內的文字會堆積在表格上方。任何想法如何解決這個問題?PHP表'和標題'的位置歪

<?php 

if($_GET["pokemon"] == 'P') 
    { 
    #query to find pokemon cards in a deck 
    <h2>Pokemon</h2> 
    <table> #print a table based on query 
    } 

if($_GET["trainer"] == 'T') 
    { 
    #query to find trainer cards in a deck 
    <h2>Trainers</h2> 
    <table> #print a table based on query 
    } 

if($_GET["energies"] == 'E') 
    { 
    #query to find energy cards in a deck 
    <h2>Energies</h2> 
    <table> #print a table based on query 
    } 

?> 
+1

你是什麼意思的'標籤內的文字堆積'?請添加屏幕截圖。 – arkascha

+0

http://web.engr.oregonstate.edu/~bainro/test3.php?pname=emily&pokemon=P&trainer=T&energy=E 您可以忽略該按鈕。我稍後會解決這個問題。 –

回答

2

請確保您關閉您的<table></table>標籤

同樣也適用於其他代碼:

<tr> 
    <th></th> 
</tr> 
<tr> 
    <td></td> 
</tr> 
+0

就是這樣!謝謝!有趣的是,它仍然有效並且做了它所做的。 –

+0

這是因爲瀏覽器具有標準的實現。 – Manatax

+0

欲瞭解更多信息,你可以去: http://www.w3schools.com/html/html_tables.asp – Manatax

1

您需要關閉所有打開的標籤..

恕我直言,你正在打開三個表格標籤,並且可能只關閉一次..

A另外,請在您的帖子中添加更多代碼。

+1

是的,就是這樣。 N00b錯誤大聲笑謝謝。 –