2012-08-06 21 views
1

我試圖用php創建鏈接,但遇到了一些困難。有人可以幫我弄這個嗎。我希望鏈接去的標題是什麼變量$行[「USER_ID」]是yourteam.php ....使用數組進行字符串插值

echo "<tr bgcolor=\"#D1D1D1\"><td>" . "<a href=\"yourteam.php\">$row['User_ID']</a>" . "</td><td><b>" . $row['Correct_Picks'] . " </b> /" . $maxcorrectpicks . "</td><td>" . $row['Points'] . "</td></tr>"; 
+0

什麼是html輸出? – Vulcan 2012-08-06 01:51:36

回答

1

當使用一個雙引號字符串數組項您遺漏任何報價

echo "<tr bgcolor=\"#D1D1D1\"><td>" . "<a href=\"yourteam.php\">$row[User_ID]</a>" . 

你也可以住變量在{}

echo "<tr bgcolor=\"#D1D1D1\"><td>" . "<a href=\"yourteam.php\">{$row['User_ID']}</a>" . 
+0

這工作!感謝狗。 – 2012-08-06 02:06:58

0

試試這個

echo "<tr bgcolor='#D1D1D1'><td><a href='yourteam.php'>".$row['User_ID']."</a></td><td><b>" . $row['Correct_Picks'] . "</b>" . $maxcorrectpicks . "</td><td>" . $row['Points'] . "</td></tr>"; 

我建議你使用<strong></strong>而不是<b></b>也可以使用內聯樣式作爲style='background-color:#D1D1D1;'而不是bgcolor

0

我知道人們使用單引號的建議,但我喜歡在我的HTML屬性上使用雙引號,並在echo語句中使用縮進來實現可讀性。以下是我該怎麼做...

echo "<tr bgcolor=\"#D1D1D1\">"; 
echo " <td><a href=\"yourteam.php\">{$row['User_ID']}</a></td>"; 
echo " <td><b>{$row['Correct_Picks']}</b>{$maxcorrectpicks}</td>"; 
echo " <td>{$row['Points']}</td>"; 
echo "</tr>";