Insert rows at the top of the table

2

I have the following problem, I created a form in which the value that the user writes has to go to the top of the table, leaving the oldest ones down, or have my SELECT select only the last 10 records of the Can anyone help me?

UPDATE !!!

My code looks like this:

$result = "SELECT id, filmes FROM dados_rec ORDER by filmes DESC LIMIT 10";
$query = mysqli_query($link, $result);

$row = mysqli_fetch_row($result);

echo $row[1];
echo $row[2];
echo $row[3];

It prints only the first, which in the case is the name of a movie, but it ignores the other "echos"

    
asked by anonymous 02.10.2016 / 17:52

2 answers

1

To get the last 10:

SELECT * FROM 'table' ORDER BY id DESC LIMIT 10

To display all rows:

$sql = "SELECT id,nome FROM 'table' ORDER BY id DESC LIMIT 10";
$result = mysql_query($sql, $connection) or die (mysql_error());
$row = mysql_fetch_array($result);


while($row = mysql_fetch_array($result))
{ 
    echo $row['id']." - ."row['nome'];
}
    
03.10.2016 / 18:36
0

No need to do this, just select the last records from the table using

SELECT * FROM dados_rec ORDER BY id DESC
    
02.10.2016 / 18:11