在我的网络应用中,我有朋友搜索,我也不知道为什么,但是当我编写要搜索的用户名时,它没有显示错误,浏览器也没有显示任何内容。谁能帮助我找到该错误? :D我的代码如下:
<div class="input">
<input type="text" class="finder" value="Find friends by username" name="friends">
</div>
<div class="friends">
<?php
require_once "connect.php";
mysqli_report(MYSQLI_REPORT_STRICT);
$connection= mysqli_connect($host, $db_user, $db_password, $db_name);
if(mysqli_connect_errno()) {
echo "Server error. Try again later.";
} else {
$friends = $_POST['friends'];
$result=$connection->query("SELECT username FROM users WHERE username = '$friends'");
$row = mysqli_fetch_assoc($result);
$username = $row['username'];
$how_much_friends = $result->num_rows;
if($how_much_friends=0) {
$_SESSION['e_friends']= '<span style="color:white"> We did not found your friends on CD Messenger. </span>';
} else {
while($row) {
if (isset($_SESSION['e_friends']))
{
echo $_SESSION['e_friends'];
unset($_SESSION['e_friends']);
} else {
echo "<div>" . $username . "</div>";
}
}
}
}
$connection->close();
?>
</div>