添加指向PHP表中某些列的链接

时间:2015-03-11 15:32:11

标签: php

如何将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++;
}

1 个答案:

答案 0 :(得分:0)

将你的if改为:

if ($field->name == "name" || $field->name == "id")