Load a base except one element dynamically

0

I would like to know how I could load a list of a base except for one element for its id. I send the id of an element with a button using the Get method to another page where I load the element. What I'm looking for is that, in another section of that same page, I can load the complete list to which that element belongs but I would like to exclude the element that I get with get.

What I try to achieve is the result shown by other websites that I have seen in which they show something like: "You might also be interested ..." I hope you understand.

link

Best regards

    
asked by jofret 15.06.2018 в 23:38
source

1 answer

0

I could recover all the data from the database listing and display them with a loop, in that loop you add a if so that the element with the id that has been received by GET is not displayed (in php I think it is continue ) so that the loop continues without displaying the element.

It would be something like this:

$elemento = $_GET['valor']
if ($resultado = $mysqli->query($consulta)) {    
    while ($fila = $resultado->fetch_assoc()) {
        if($fila["imgen"] == $elemento) {
          continue;
        }
        mostrar_elemento();
    }
}
    
answered by 16.06.2018 / 00:21
source