简体   繁体   English

如何在我的 foreach 语句中放置 href 链接?

[英]How can i put an href link in my foreach statement?

For starters i am fairly new at this.对于初学者来说,我对此还很陌生。 I am trying to figure out how to a href link my row 'inspection_files' and i have tried just about everything.我想弄清楚如何将我的行“inspection_files”链接到一个 href 链接,我几乎尝试了所有方法。 Is there anybody who could help me?有没有人可以帮助我?

<?php
$i = 0;
foreach ($result as $r) {
    echo "<tr>";
    echo "<td>" . $r['last_inspection'] . "</td><td>" . strtolower(trim(($r['inspected_by_company']))) . "</td><td>" . strtolower(trim($r['inspection_files'])) . "</td>";
    echo "</tr>";

    $i++;
}
?>

Hey you can directly use <a> tag inside the <td> , just like below嘿,你可以直接在<td>使用<a>标签,就像下面一样

echo "<td>" . $r['last_inspection'] . "</td><td>" . strtolower(trim(($r['inspected_by_company']))) . "</td><td><a href='" . strtolower(trim($r['inspection_files'])) . "'>" . strtolower(trim($r['inspection_files'])) . "</a></td>";

I hope $r['inspection_files'] this is your URL if this is not your redirect URL then just replace with your actual URL.我希望$r['inspection_files']这是您的 URL,如果这不是您的重定向 URL,那么只需替换为您的实际 URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM