链接在本地主机而不是实际网站重定向

时间:2016-06-02 09:40:20

标签: php sql html5

我有一张不同列的表格。他们是网站,点击时应该将我重定向到一个网站。但它正在我的本地主机上查看网站。

  

http://127.0.0.1:8090/test/http://www.amity.edu/mauritius/

应该是

  

http://www.amity.edu/mauritius/

这是表格的代码:

nub(L) -> sets:to_list(sets:from_list(L)).

我该怎么做才能进入网站? 提前谢谢。

3 个答案:

答案 0 :(得分:2)

更改此项,使用href的单引号,并使用协议

<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

答案 1 :(得分:1)

您需要在http://https://

之前添加网址
echo "<td><a href='http://" . $row['website'] . "'>" . $row['website'] . "</a></td>";

答案 2 :(得分:0)

如果变量$row['website']在开始时有http://,它会重定向到http://www.amity.edu/mauritius/,否则会在开始时附加本地主机网址。

试试这个:

<?php
include ('db_connect.php');
$sql="select * from institution";
$result= mysqli_query($conn, $sql);

while ($row = mysqli_fetch_array($result)){

    echo "<tr>";
    echo "<td>" . $row['ins_id'] . "</td>";
    echo "<td>" . $row['ins_name'] . "</td>";
    echo "<td>" . $row['address'] . "</td>";
    echo "<td>" . $row['contact'] . "</td>";
    echo "<td><a href=" . addhttp($row['website']) . ">" . $row['website'] . "</a></td>";
    echo "<td>" . $row['email'] . "</td>";

    echo "</tr>";
}
echo "</table>";


function addhttp($url) {
    if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
        $url = "http://" . $url;
    }
    return $url;
}