1
I have a table in the database with several lines,
I wanted to get the highest id, which has status = 1, how can I do this with php? The id is a table column and the status is another.
Then I also want to know how I get the lowest.
<?php
$link = mysqli_connect("localhost", "root", "vertrigo", "csgodouble");
$contador = 0;
$verifica = mysqli_query($link, "SELECT MAX(id) FROM apostas WHERE status = 1 ");
$sql = mysqli_fetch_array($verifica);
echo $sql["numero_sorteado"];
?>
Can you give me an answer with the code please?
– Gonçalo
@Gonçalo post his select and how it travels , because I’m by cell phone...
– Augusto Furlan
From here I get the highest id with status = 1?
– Gonçalo
S, because the order by id desc sorts the id lines in descending, and Where only picks id with status 1
– Augusto Furlan
I couldn’t get it with your code.
– Gonçalo
I just got.
– Gonçalo
Q ue bom @Gonçalo ...
– Augusto Furlan
@Augustofurlan adapted his answer, because I edited the question with a question more from the author, all right? I just added the reverse option.
– Bacco