我有一個mysql表中的字段存儲的ProjectTeam值爲(val1,val2) 我想要將每個值在ProjectTeam到HTML中,每個必須鏈接到一個分離的鏈接。 我怎樣才能回聲每個數組元素。下面的代碼正確顯示,但所有值都標識爲一個鏈接。任何幫助表示讚賞。單獨的字符串到數組
function list_account_projects($new_projectAccount){
$this->projectAccountName = $new_projectAccount;
$listQuery = mysql_query("SELECT * from projects
WHERE projectAccount = '$this->projectAccountName'");
while ($rows = mysql_fetch_array($listQuery)){
$this->projectName = $rows['projectName'];
$this->projectType = $rows['projectType'];
$this->projectTeam = $rows['projectTeam'];
$this->projectOwner= $rows['projectOwner'];
$this->projectStartDate = $rows['projectStartDate'];
//Convert date backwards
$re_projectStartDate = date('m-d-y', strtotime($this->projectStartDate));
//split ProjectTeam ',' - Optional
$splitUsers = explode(',', $this->projectTeam);
foreach($splitUsers as $user) {
$user = trim($user);
}
echo "
<div class=\"list-group\">
<a class=\"list-group-item active\" href=\"#\">$this->projectName <p class=\"pull-right\">Due Date: $re_projectStartDate</p></a>
<a class=\"list-group-item \" >
Project Name: $this->projectName</br>
Project Type: $this->projectType</br>
Project Owner: $this->projectOwner</br>
Project Team: <a href=\"$user\">$user</a></a>
</div>
";
}
http://www.php.net/manual/en/function.str-split.php – underscore
你不能使用嵌套一個標籤 –