返回格式为<a> link [ajax]

时间:2015-05-30 21:48:51

标签: html mysql ajax

I want to return a mysql query result field to html as a clickable formatted link.

//I want to format clmLink as a clickable link
while($row = mysql_fetch_array($qry_result)){
    $display_string .= "<tr>";
    $display_string .= "<td class='td1'>$row[clmDate]</td>";        
    $display_string .= "<td class='td2'>$row[clmnames]</td>";
    $display_string .= "<td class='td3'>$row[clmComment]</td>";
    $display_string .= "<td class='td4'>$row[clmLink]</td>";               
    $display_string .= "</tr>"; 
<head>                  
    <style> 
         .td4 {
             padding-right: 20px;
             padding-top: 10px;
             background-color: #E6E6FA;
             width: 100px;          
        }           
    </style>         
</head> 

1 个答案:

答案 0 :(得分:3)

您可以添加<a>标记,如下所示:

$display_string .= '<td class="td4"><a href="'.$row[clmLink].'">'.$row[clmLink].'</a></td>'

如果您不想只使用<td>,则必须使用一些Javascript来使<td>可点击并添加一些这样的CSS:

.td4{
    cursor : pointer;
    color : blue;
}
.td4:hover{
    color : light-grey;
}