2013-04-02 47 views
1

我正在從一個mysql表打印數據到我的網頁上的一個表。這裏是代碼表數據只顯示第一個字母的條目

 Print "<table border cellpadding=5>"; 
     Print "<tr><th>Name:</th> <th>Size:</th> <th>Depth:</th> <th>Boat Access:</th> 
     <th>All Sports:</th> <th>Public Beach:</th> <th>Fish Species:</th> <th>Comments: 
     </th></tr>"; 
     while($info = mysql_fetch_array($data)) 
     { 
     Print "<tr>"; 
     Print " <td>".$info['member'] . "</td> "; 
     Print "<td>".$info['size'] . " </td>"; 
     Print " <td>".$info['depth'] . "</td> "; 
     Print " <td>".$info['access'] . "</td> "; 
     Print " <td>".$info['sports'] . "</td> "; 
     Print " <td>".$info['beach'] . " </td>"; 
     Print" <td>".$info['bluegill'] ." </td>"; 
     Print " <td>".$info['comments'] . "</td> "; "</tr>"; 
     } 
     Print "</table>"; 

它的工作方式很好,但我的問題是如何將多個值放在同一個表數據。我嘗試了幾種不同的方式,沒有任何工作。如果我把 $ info ['bluegill'] [海灘]它只輸入表中第一個條目的第一個字母。 有什麼建議嗎?

+1

[**請不要在新代碼'mysql_ *'功能** ](http://bit.ly/phpmsql)。他們不再被維護[並且被正式棄用](http://j.mp/XqV7Lp)。看到[**紅框**](http://j.mp/Te9zIL)?學習[*準備的語句*](http://j.mp/T9hLWi),並使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [這篇文章](http://j.mp/QEx8IB)將幫助你決定哪個。 – Kermit

+0

你在問如何回顯一個變量? – Pitchinnate

回答

3

串連每個打印這樣

Print " <td>". $info['member'] . $info['thing'] . "</td> "; 

,這將讓你在每個表箱呼應額外價值

+0

感謝一堆亞當。可以發誓我嘗試過,但不要猜測,因爲它現在起作用。 – karlh

+0

不客氣。我用PHP開始時遇到了完全相同的問題:) –

相關問題