【发布时间】:2021-10-09 03:02:12
【问题描述】:
我在 phpMyAdmin 中创建了一个数据库,我有 10 行数据,每行都有一个列来显示其网站地址。我想让网站地址可点击。
我使用下面的数组方法来显示我的网址链接,但它不起作用
$website = array(
array("Google","https://code.tutsplus.com"),
array("Bing","https://weatherstack.com"),
array("W3","https://www.w3schools.com")
);
foreach ($website as $urlitem){
echo "<a href='".$urlitem[1]."'></a>";
}
// this gets an associative array (ie the keys can be used as well as the indicies)
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
// The below code displays my table
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['type'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['street'] . "</td>";
echo "<td>" . $row['city'] . "</td>";
echo "<td>" . $row['region'] . "</td>";
echo "<td>" . $row['code'] . "</td>";
echo "<td>" . $row['phone'] . "</td>";
echo "<td><a href='".$urlitem[0]."'>" .$row["website"] ."</td>";
echo "</tr>";
}
}
【问题讨论】: