how to view the records by user

0

Good evening, I'm doing a system for booking juices in php, but what happens is that when making a booking record, all users can see the reservations of others and I just want them to see their own reservation.

//este codigo es para mostrar las reservas
 <?php
   $consulta="select * from reserva";
    $ejecutar=mysqli_query($con,$consulta);
    $i=0;
    while($fila=mysqli_fetch_array($ejecutar)){
        $dni=$fila['dni'];
        $nombres=$fila['nombre'];
        $apellidos=$fila['apellido'];
        $jugo=$fila['jugo'];
        $fecha=$fila['fecha'];
        $i++;

    ?>

    
asked by douglas 09.11.2017 в 19:53
source

2 answers

0

You must put the condition in the select that only the user sees it, that is, where you make the variable $ query and then the select must put a 'where' equal to username or something similar. Example: $ query="select * from reserve where userID = 5978";

    
answered by 09.11.2017 в 20:12
0

Use:

$consulta="select * from reserva where dni='<numero de dni>'";

or also

$consulta="select * from reserva where dni='<numero de dni>' or (nombre='<nombre aquí>' and apellido='<apellido aquí>')";
    
answered by 09.11.2017 в 20:05