2
I am developing an App that uses a page PHP
where I will have a ranking of points that the user makes when performing some interaction with it. I have a script that generates the list in order (from largest to smallest) showing from first to last.
However I wish to HIGHLIGHT the user who makes the query, passed through a form ($user =$_GET['user'];), formatting your line in bold. I believe to be an IF condition but I can’t get to the problem resolution.
Quote my current code, working perfectly, but without highlighting the user who makes the query.
$usuario =$_GET['usuario'];
$conexao = mysqli_connect('XXXXXXX','XXXXXX','XXXXXXX');
mysqli_select_db($conexao,'XXXXXX');
$sql="select * from login order by pontos DESC";
$resultado = mysqli_query($conexao,$sql) or die ("Erro: " . mysqli_error());
$posicao = 1; //variavel
echo <table width='90%' style='padding:10px;'><tr><td width='20%'><b>Class.</td><td width='60%'><b>Participante</td><td width='20%'><b>Pontos</td>";
//faz um looping e cria um array com os campos da consulta
while($array = mysqli_fetch_object($resultado)) {
echo "<tr><td>";
echo $posicao; // COLUNA DA POSIÇÃO NO RANKING
echo "</td><td>";
echo $array->usuario; // AQUI EU QUERO UM IF PARA DIFERENCIAR O USUÁRIO PASSADO LÁ EM CIMA.
echo "</td><td>";
echo $array->pontos; // coluna dos pontos
echo "</td></tr>";
$posicao = $posicao + 1; // acumula próxima posição até terminar
}
echo "</table>"
Hello, welcome to Stack Overflow in English if you haven’t done a community tour, access here, and learn how to elaborate your questions and answers. By the way, your code is with some quote errors... probably this could be causing your script errors.
– Ivan Ferrer
Hello Ivan, thank you for your support. As I commented in the Post. The code DOES NOT contain errors, it is working perfectly, I just want to ADD this functionality to it. The possibility to, when making the loop, identify the user in the BD and check if it is the same $user passed through the $_GET.
– Leoman Alves Moitinho
@Leomanalvesmoitinho As you are new here, I suggest you see [Ask] and also tell you that it is not a forum, so you do not have to edit the question with "solved" in the title, but only mark the correct answer. This site is a Q&A. Welcome.
– Renan Cavalieri
Thank you for your guidance. I’m new because I just registered, but I use as a learning (as well as thousands of other people) all the questions and answers from the site. I recommend in trainings that I give to students to research in their vast library of knowledge and share the results.
– Leoman Alves Moitinho