I'm having a problem when creating a system, I need to do a select:
$select = $mysqli->query("SELECT * FROM 'guild' WHERE 'user_id'='$userid'");
$row = $select->num_rows;
$get = $select->fetch_array();
$guild = $get['guild'];
Transform the variable $guild
into one array and get it in the other select
$select = $mysqli->query("SELECT * FROM 'guild' WHERE 'guild' != '$guild' AND 'user_id' != '$userid' ORDER BY 'score' DESC LIMIT 5");
$row = $select->num_rows;
$get = $select->fetch_array();
$guild_name = $get['guild'];
$guild_icn = $get['icn'];
$guild_score = $get['score'];
Exactly what I need is that all select
results are removed in this array
, but I have no idea how to do it.
Complete code:
<?php
require_once ("includes/connection.php");
require_once ("includes/start-session.php");
require_once ("includes/encript.php");
$ip = $_SERVER["REMOTE_ADDR"];
$iusername = "Trabzera";
$userid = "10";
$select = $mysqli->query("SELECT * FROM 'data' WHERE username='$iusername' AND 'ip'='$ip'");
$row = $select->num_rows;
$get = $select->fetch_array();
if ($row > 0) {
$select = $mysqli->query("SELECT * FROM 'guild' WHERE 'user_id'='$userid'");
$row = $select->num_rows;
$get = $select->fetch_array();
$guild = $get['guild'];
#----------------------
$select = $mysqli->query("SELECT * FROM 'guild' WHERE 'guild' != '$guild' AND 'user_id' != '$userid' ORDER BY 'score' DESC LIMIT 5");
$row = $select->num_rows;
$get = $select->fetch_array();
$guild_name = $get['guild'];
$guild_icn = $get['icn'];
$guild_score = $get['score'];
$score_result = round($guild_score/1000);
$count = 1;
echo '<div id="guild-central">Central da Guild</div>
<div id="guild-central-msg">Selecione abaixo a opção desejada:</div>
<menu id="create-guild">
<div id="create-guild-msg">Criar uma Guild</div>
<div id="create-guild-txt">Para criar uma Guild é necessário alguns requerimentos:</div>
<div id="create-guild-req1">- Nível 10+</div>
<div id="create-guild-req2">- 1000 KP (Knautiluz Points)</div>
<div id="create-guild-reqok">Caso atenda esses requsistos clique abaixo:</div>
<button id="create-guild-button">Criar uma Guild</button>
</menu>';
echo '<menu id="join-guild">
<div id="join-guild-msg">Juntar-se a uma Guild</div>';
#-----------------------------------------------------
if ($row > 0) {
while ($count <= $row) {
echo'
<script>
$("#guild-join-request-'.$count.'").click (function() {
var guildName = $("#guild-join-name-'.$count.'").html();
var src = $("#guild-join-icn-'.$count.'").attr("src");
var iusername = "'.$iusername.'";
var userid = "'.$userid.'";
$.ajax({
url: "systems/join-guild.php",
type: "POST",
data: {iusername: iusername, userid: userid, guildName: guildName, src: src},
beforeSend: function() {
$("#sucess").html("Carregando...");
},
success: function (result) {
$("#user-painel-2").html(result);
}
});
});
</script>';
echo'
<div id="guild-join-'.$count.'" class="guild-join">
<img src="'.$guild_icn.'" id="guild-join-icn-'.$count.'"></img>
<div id="guild-join-name-'.$count.'" class="guild-join-name">'.$guild_name.'</div>
<div id="guild-join-score-'.$count.'" class="guild-join-score" >- '.$score_result.'K</div>
<input style="cursor:pointer;" type="button" id="guild-join-request-'.$count.'" value="Solicitar" class="guild-join-request"></input>
<div id="guild-join-underline-'.$count.'" class="guild-join-underline"></div>
</div>';
$get = $select->fetch_array();
$guild_name = $get['guild'];
$guild_icn = $get['icn'];
$guild_score = $get['score'];
$score_result = round($guild_score/1000);
$count++;
}
echo'<menu id="guild-request">
<div id="guild-request-msg">Solicitações Pendentes:</div>';
#---------------------------------------------------------------
$select = $mysqli->query("SELECT * FROM 'guild' WHERE 'user_id' ='$userid'");
$row = $select->num_rows;
$get = $select->fetch_array();
$guild_name = $get['guild'];
$guild_icn = $get['icn'];
$guild_score = $get['score'];
$score_result = round($guild_score/1000);
$count = 1;
if($row > 0) {
while ($count <= $row) {
echo'
<div id="guild-request-'.$count.'" class="guild-request">
<img src="'.$guild_icn.'" id="guild-request-icn-'.$count.'"></img>
<div id="guild-request-name-'.$count.'" class="guild-request-name" >'.$guild_name.'</div>
<div id="guild-request-score-'.$count.'" class="guild-request-score">- '.$score_result.'K</div>
<button id="guild-request-cancel-'.$count.'" class="guild-request-cancel">Cancelar</button>
<div id="guild-request-underline-'.$count.'" class="guild-request-underline"></div>
</div>';
$get = $select->fetch_array();
$guild_name = $get['guild'];
$guild_icn = $get['icn'];
$guild_score = $get['score'];
$score_result = round($guild_score/1000);
$count++;
}
echo '</div>
</menu>';
} else {
echo'
<menu id="guild-request">
<div id="guild-request-msg">Solicitações Pendentes:</div>
<div id="no-requests">Nenhuma solicitação pendente.</div>
</menu></menu>';
}
#---------------------------------------------------------------
} else {
echo "Ainda não existe nenhuma guild.";
}
} else {
echo "Erro.";
}