[英]Add links to certain columns in PHP table
如何使php-> html的某些列成為鏈接? 目前,我正在嘗試獲取每個標題行,並根據標題打印鏈接。 這是我的代碼:
// printing table rows
$rowCtr = 1;
while($row = mysql_fetch_row($result)){
$i = 0;
foreach($row as $cell){
// This is the part not working.
$field = mysql_fetch_field($result, $i);
if ($field->name == "name" || "id"){
$link = "http://random.com?Ident={$cell}";
echo "<td><a href='$link'>$cell</a></td>";
} else {
echo '<td>$cell</td>';
}
$i++;
}
echo '</tr>\n';
$rowCtr++;
}
將您的if更改為此:
if ($field->name == "name" || $field->name == "id")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.