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

Php 链接在本地主机中重定向,而不是在实际网站中重定向,php,sql,html,Php,Sql,Html,我有一张不同列的桌子。其中一个是网站,当我点击它时,它会将我重定向到一个网站。然而,它正在我的本地主机上查找该网站 应该是 以下是表格的代码: <?php include ('db_connect.php'); $sql="select * from institution"; $result= mysqli_query($conn, $sql); while ($row = mysqli_fetch_array($result)){ echo "<tr>

我有一张不同列的桌子。其中一个是网站,当我点击它时,它会将我重定向到一个网站。然而,它正在我的本地主机上查找该网站

应该是

以下是表格的代码:

<?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=" . $row['website'] . ">" . $row['website'] . "</a></td>";
echo "<td>" . $row['email'] . "</td>";

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

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

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

$protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://';
echo "<td><a href='" $protocol. $row['website'] . "'>" . $row['website'] . "</a></td>";
$protocol=stripos($\u SERVER['SERVER\u protocol'],'https')==true?“https://':'http://';
回声“;

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

$protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://';
echo "<td><a href='" $protocol. $row['website'] . "'>" . $row['website'] . "</a></td>";
$protocol=stripos($\u SERVER['SERVER\u protocol'],'https')==true?“https://':'http://';
回声“;

您需要在URL前面加上
http://
https://

echo "<td><a href='http://" . $row['website'] . "'>" . $row['website'] . "</a></td>";
echo”“;

您需要在URL前面加上
http://
https://

echo "<td><a href='http://" . $row['website'] . "'>" . $row['website'] . "</a></td>";
echo”“;

如果变量
$row['website']
在start中有
http://
,它将重定向到
http://www.amity.edu/mauritius/
否则它将在start中附加本地主机url

试试这个

<?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;
}

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

试试这个

<?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;
}

它仍在我的本地主机上查找它。正如拉凯什所说的,检查数据库表中的
列网站
?您有什么价值?我的数据库中存储了链接(www.amity.edu/mauritis)。表td中显示了相同的价值?正确的?将鼠标悬停在状态栏上后会得到什么?我的意思是whesite url?是的,显示的是相同的值。当鼠标悬停时,不会显示任何内容。它仍在我的本地主机上查找。正如rakesh所说,请检查数据库表中的列
网站
?您有什么价值?我的数据库中存储了链接(www.amity.edu/mauritis)。表td中显示了相同的价值?正确的?将鼠标悬停在状态栏上后会得到什么?我的意思是whesite url?是的,显示的是相同的值。悬停时,不会显示任何内容。