0
With this code, how do I make the return of the query come in order decreasing?
<?php
session_start();
include_once "conexao.php";
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>CRUD - Pesquisar</title>
</head>
<body>
<center>
<a href="http://localhost/aula/index.php">
<button> Menu </button> </a>
<h1>Pesquisar Pré Picking</h1>
<?php
if(isset($_SESSION['msg'])){
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
?>
<form method="POST" action="">
<label>Nome: </label>
<input type="text" name="nome" placeholder="Digite o nome"><br><br>
<input name="SendPesqUser" type="submit" value="Pesquisar">
</form><br><br>
<?php
$SendPesqUser = filter_input(INPUT_POST, 'SendPesqUser', FILTER_SANITIZE_STRING);
if($SendPesqUser){
$nome = filter_input(INPUT_POST, 'nome', FILTER_SANITIZE_STRING);
$result_usuario = "SELECT * FROM pessoas1 '; WHERE nome LIKE '%$nome% ORDER BY `data` DESC";
$resultado_usuario = mysqli_query($conn, $result_usuario);
while($row_pessoas1 = mysqli_fetch_assoc($resultado_usuario)){
echo "ID:" . $row_pessoas1['id'] . "<br>";
echo "Nome:" . $row_pessoas1['nome'] . "<br>";
echo "Rua:" . $row_pessoas1['rua'] . "<br>";
echo "Tipo:" . $row_pessoas1['tipo'] . "<br>";
echo "Lista:" . $row_pessoas1['lista'] . "<br>";
echo "Data:" . $row_pessoas1['data'] . "<br><hr>";
echo "<a href='edit_usuario.php?id=" . $row_pessoas1['id'] . "'>Editar</a><br><hr>";
}
}
?>
</center>
</body>
</html>
You do not have this ; before WHERE. O ; indicates the end of an SQL command.
– anonimo
sorry I didn’t understand that ordr by I put no more god right deconsidere it
– Felipe Vasconcelos
what the code I sent would look like
– Felipe Vasconcelos
$result_usuario = "SELECT * FROM people1 WHERE name LIKE '%$name%' ORDER BY
data
DESC;";– anonimo
Note 1,000 worked 100% thank you very much !!!
– Felipe Vasconcelos
as resolved, it is worth putting the solution as an answer so that the question does not remain open (why accept an answer) ;)
– rLinhares