我正在更新我的搜索页面的代码,出于某种原因,如果您搜索任何用户,例如有三个用户名为“Peter”,如果您搜索它们,则第一个Peter仅打印输入:
<input type="hidden" name="chatting_with" value="userexample"/><input type="hidden" name="chatting_logusr" value="userexample"/><input id="prponclick" class="openchatmsgdevices" type="submit" value="Enviar un mensaje" />
但其余部分使用以下形式正确打印:
<form target="u-n" method="POST" action="open_new_chat_with_user"><input type="hidden" name="chatting_with" value="userexample"/><input type="hidden" name="chatting_logusr" value="userexample"/><input id="prponclick" class="openchatmsgdevices" type="submit" value="Enviar un mensaje" /></form>
下面是完整的代码:
<?php
session_start();
include("../DD/ddd.php");
$logged_user = $_SESSION['valid_user'];
if(!$logged_user){return false;}
$query = "SELECT searched_for FROM searches WHERE `user` = '$logged_user' ORDER BY id_search DESC LIMIT 1";
$run_query = $all_conn->query($query);
$rows_searches = $all_conn->query($query)->fetch();
$searched_for = $rows_searches['searched_for'];
$no_allowed_spaces = preg_replace('/\s/', '', $searched_for);
$query_info = "SELECT * FROM user_info WHERE nombre LIKE '%".$searched_for."%' OR `user` LIKE '%".$searched_for."%'";
echo '<div class="n-ovf" style="overflow:auto;">';
if(strlen($searched_for) >= 1)
{echo '<a href="../search/?q='.$searched_for.'&type=search'.'"><div id="search-ico-con"><div id="s-ico-con"></div><div id="s-l-dvsr-con"><div id="s-l-dvsr"></div></div><div id="s-txt-con"><h3>'.$searched_for.'</h3></div></div><div id="s-dvsor"></div></a>'.
'<a href="../search/?q='.$no_allowed_spaces.'&type=tag'.'"><div id="search-hastag-con"><div id="s-hastag-con"><h1>#</h1></div><div id="shtag-l-dvsr-con"><div id="shtag-l-dvsr"></div></div><div id="shtag-txt-con"><h3>'.$no_allowed_spaces.'</h3></div></div><div id="shtag-dvsor"></div></a>';}
foreach($all_conn->query($query_info) as $got_users){
if(strlen($searched_for) == 0){echo '<div class="search-for-something"><h3>Buscar algo....</h3></div>'; return false;}
echo '<div class="searched-content-info">
<div style="float:left; width:100%; height:0.1px; position:relative; z-index:9586;" class="container-buttons-search-user">
<form target="u-n" method="POST" action="open_new_chat_with_user"><input type="hidden" name="chatting_with" value="'.$got_users['user'].'"/><input type="hidden" name="chatting_logusr"
value="'.$logged_user.'"/><input id="prponclick" class="openchatmsgdevices" type="submit" value="Enviar un mensaje" />
</form>
<a href="../success/profile?search_user='.$got_users['user'].'"><input type="button" value="Visitar árbol"/></a>
</div>'.
'<div class="searched-photo"><img src="'.$got_users['foto'].'"></div>
<div class="searched-names"><h3>'.$got_users['nombre'].'</h3></div>
</div>
<div class="divisor-search-user"></div>';
}
echo '<div class="all-searched-content-divisor"></div>';
echo '</div>';
?>