I need to know how to compare two records in php with mysqli

0

The code is as follows, it is for a university project, I am making a cup model and I am inserting matches and I need to validate that the two selections are from the same group, here the code but does not work

<?php 
require_once 'conexion.php';
$seleccion1 = $_GET['Seleccion1'];
$seleccion2 = $_GET['Seleccion2'];

$grupo_seleccion1 = $con -> query("select Grupo from Seleccion where Nombre='$seleccion1'");
$grupo_seleccion2 = $con -> query("select Grupo from Seleccion where Nombre='$seleccion2'");
if($fila1 = $grupo_seleccion1 -> fetch_assoc()){
    $var1 = $fila1['Nombre'];
}


if($fila2 = $grupo_seleccion2 -> fetch_assoc()){
    $var2 = $fila2['Nombre'];
}
var_dump($var1);
if ( $var1 == $var2) {
    echo "Son del mismo grupo";
}
else{
    echo "No son del mismo grupo";
}
?>
    
asked by Jesus Contreras 01.09.2018 в 04:12
source

1 answer

2

Good friends, thanks, I found the problem was that I was calling the wrong field, just change $fila1['Nombre'] and $fila2['Nombre'] $fila1['Grupo'] $fila2['Grupo'] respectively thanks and sorry for the inconvenience

    
answered by 01.09.2018 в 04:38