你能帮我解决一下如何从mysql数据库访问所有从数组中获取的结果吗?我正在运行下面的代码,但是对于满足搜索条件的结果,我在一个数组中得到没有空格的所有结果,例如$ username变量收集一行中没有满足特定搜索条件的空格的所有用户名。如何将所有这些结果分成单个结果?我尝试了一些字符串函数,但它不起作用。 非常感谢你提前!
$sqlCommand = "(SELECT * FROM users WHERE country LIKE '%$searchquery%' OR city LIKE '%$searchquery%' OR town LIKE '%$searchquery%')";
$query = mysqli_query($cn, $sqlCommand) or die(mysqli_error($cn));
$count = mysqli_num_rows($query);
if($count > 1){
$search_output .= "<hr />$count results for <strong>$searchquery</strong><hr />$sqlCommand<hr />";
while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){
$url = $row["url"];
$url.='   ';
$url1 = strtok($url," ");
$id = $row["id"];
$f_name = $row["f_name"];
$l_name = $row["l_name"];
$user = $f_name;
$user.= " ";
$user.= $l_name;
$username = $row["username"];
$username.=' <br>';
// nl2br( $url, true);
$search_output .= '<a href="user.php?u=$username">'. $user . ' </a><br />';
}