php - 使用 PHP 从 SQL 数据库中获取 url 时如何引入锚链接?
问题描述
这是 PHP 脚本,我可以将数据加载到数据库中,但链接行中的元素似乎不可点击。所以我重定向了用户。我的尝试是添加类似于表定义的 anchor() 标签,但它仍然处于非活动状态。
<?php
$con=mysqli_connect($server,$user,$password,$dbname);
// Check connection
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM accident_log");
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Link</th>
</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['ID'] . "</td>";
echo "<a><td>" . $row['Link'] . "</td></a>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
解决方案
如果您不知道,请在这里学习https://www.w3schools.com
echo '<td><a href="' . $row['link'] . '">' . $row['link'] . '</a></td>';
echo '<td><a href="' . $row['link'] . '" style="background: #09f; color: #fff; padding: 10px 20px;">' . $row['link'] . '</a></td>';
推荐阅读
- ios - 通过 NFC Swift/iOS 连接蓝牙设备
- python - 使用 Python 生成器的直方图问题?
- reactjs - Reactjs wordpress 为 SEO 预渲染现有的客户端应用程序
- sql - 更新 sql 获取多于一行的选择
- java - 如何在 javaFX 中限制/设置帧速率?
- python - 创建列表时检查列表中的值的复杂性
- ios - 如何以编程方式快速定位图层?
- laravel - App\Http\Requests\UserUpdateRequest::user() 的声明应该与 Illuminate\Http\Request::user($guard = NULL) 兼容
- arduino - Win10 <-> USB <-> Arduino - 与 Autohotkey 通信的问题
- objective-c - 在 Objective-C 目标中使用 Swift 的问题