如何通过搜索他并点击其链接来查看用户个人资料

时间:2018-03-08 08:14:00

标签: php html mysql profile

在这里我创建了一个客户链接。

<a name="id" href="https://127.0.0.1/new taxicab/account/driver/profile/index.php?id=<?php echo $data['id']; ?>"><?php echo $data['fullname']; ?></a>

并且index.php是

    <?php $connection = new mysqli("localhost", "root", "black9024!@","new_taxicab");
$id = ($_GET['id']);
if (empty($_GET['id'])){
    header("location:cheat.php");
    die();
    $sql = "select * from driver where id = '$id'";
    $result = $db->sql_query($sql) or die (mysqli_error($sql));
    while($rws = mysqli_fetch_array($result)){}
    echo $rws['fullname'];?>
    <?php echo $rws['fullname'];

  }
?>

但它无法正常工作我知道错了,但写的是什么请给我一些建议。

2 个答案:

答案 0 :(得分:1)

在你的while循环中,echo $ rws ['fullname']超出了while的花括号。尝试:

<?php

$connection = new mysqli("localhost", "root", "black9024!@","new_taxicab");

$id = ($_GET['id']);

if (empty($_GET['id'])){

 header("location:cheat.php");
die();
}

$sql = "select * from driver where id = '$id'";
$result = $db->sql_query($sql) or die (mysqli_error($sql));

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

echo $rws['fullname'];   <-- Here

};

?>

答案 1 :(得分:0)

<?php

    $connection = new mysqli("localhost", "root", "black9024!@","new_taxicab");

    if (empty($_GET['id'])){

         header("location:cheat.php");
         die();
    }

    $sql = "select * from driver where id = '$_GET[‘id’]'";
    $result = $db->sql_query($sql) or die (mysqli_error($sql));

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

        echo $rws;

    };

 ?>

可能需要更改我从手机输入的单引号

@joseph_J你的答案看起来会起作用但是你需要回应$ rws本身吗?

从我可以看到你没有将数据作为带有项目ID和全名的数组返回?$data[‘id’]这是来自哪里?