0

I have a Mysql database, where the records are sorted by positions. How do I display. The data that is before a position, and not show the data of the following positions?

PHP invoke data

$r_ruta = $_GET["r_ruta"]; 
$jornada = $_GET["jornada"]; 
$query = mysqli_query($con, 'SELECT * '.
                            'FROM escolar '.
                            "WHERE r_ruta = '$r_ruta' ".
                              "AND jornada = '$jornada' ".
                            'ORDER BY pos ASC');
sorak
  • 2,607
  • 2
  • 16
  • 24

1 Answers1

0

Using above query, you will get this id, say $id. Then next query for previous id can be like this -

        $query = mysqli_query($con, 'SELECT * '.
                            'FROM escolar '.
                            "WHERE id < '$id' ".
                            'ORDER BY id DESC LIMIT 1');
T.Shah
  • 2,768
  • 1
  • 14
  • 13