I have a problem with a function that I'm doing since it only gives me the primary data of the table and not a list NOTA:
if it works with the echo
but it comes out at the top of the site and what I want is that it works with return
since I'm using HOOKS for the good system I hope you can help me and thanks
function system_contact() {
global $con,$db,$error,$lang_text;
$userID = userdata('userID',true);//User in session
//->
$sql = mysqli_query($con,"SELECT * FROM ".T_FRIENDS." WHERE user_one = '$userID' OR user_two = '$userID' ")or die(mysqli_error());
$query = $sql;
$num_rows = mysqli_num_rows($query);
if ($num_rows != 0 ){
while($row = mysqli_fetch_array($sql)){
$user_one = $row['user_one'];//user one
if($user_one == $userID){
$user_two = $row['user_two'];
$friends = mysqli_query($con,"SELECT * FROM ".T_USERS." WHERE userID = '$user_two'")or die(mysqli_error());
$fila = mysqli_fetch_array($friends);
$result_list[] = $fila;
foreach($result_list as $fila){
$ECHO_CODE = '
<div class="wall_chat_users">
<img id="image_user_chat" src="./assets/img/avatar_default.png"></img>
<p id="name_user_chat">'.$fila['user'].'<spam class="message_counter_user_spam">42</spam></p>
</div>
';
}
return @$ECHO_CODE;
}else{
$friends = mysqli_query($con,"SELECT * FROM ".T_USERS." WHERE userID = '$user_one'")or die(mysqli_error());
$fila = mysqli_fetch_array($friends);
$ECHO_CODE = '
<div class="wall_chat_users">
<img id="image_user_chat" src="./assets/img/avatar_default.png"></img>
<p id="name_user_chat">'.$fila['user'].'<spam class="message_counter_user_spam">42</spam></p>
</div>
';
foreach($friends as $fila){
}
//return @$ECHO_CODE;
}
}
}else{
$ECHO_CODE = '
<div id="user_no_contact">
<img class="user_no_contact_img" src="{{CONFIG theme_url}}/img/no_contact.png"></img>
<p class="user_no_contact_p" >{{ADD_TEXT You_have_no_contact}}</p>
</div>
<!--You don\'t have friends-->
';
return @$ECHO_CODE;
}
}
1- The data if they are in the database.
2- In this function I receive the data of the function that is above in the question as I do it I am using HOOKS
for that, for those who do not know what the HOOKS
is something like a plugin as well as use wordpress.
3- With this function I look for the selected text that is in the frame and thus I put the function inside the DIV
.
4- When I use the function echo
if you give me the list with the data but give it to me in the TOP and not within the DIV
error.
5- if I use the return
function if it gives me the data inside the DIV but only the primaro gives me not a list.
What can I do with it or where is the problem?