0
For example, I did a search of all user data in the database to echo in different columns by the site:
$stmt = $conexao->prepare("SELECT * FROM esc_usuarios WHERE usu_codigo = ?");
$stmt->bind_param("s", $usu_codigo);
$stmt->execute();
$usu_info_result = $stmt->get_result();
$usu_info_coluna = $usu_info_result->fetch_assoc();
$stmt->close();
Elsewhere on the site, I wanted to show this result though, using an ORDER BY or LIMIT, such as:
$stmt = $conexao->prepare("SELECT * FROM esc_usuarios WHERE usu_codigo = ? ORDER BY usu_datacadastro DESC LIMIT 5");
How can I do this without having to prepare another query, since I already have the result and just want to filter the output?
There’s no way to call
resulton the page you want and take from it just what you want?– MagicHat
@Magichat So, the part of picking up specific columns I know how to do, but filter with an order by or limit is that I don’t know the syntax.
– Luann Sousa
Um... it’s a specific question of
sqlthen?– MagicHat
I believe so...
– Luann Sousa
But it is giving error this your query?
– MagicHat
No, the query works perfectly, the problem is that I want to display the results of the first query elsewhere, without having to prepare another query, since the data I want, have already been searched in the first query, I just want to format with an order by
– Luann Sousa
Type, you want to export the stored value from one variable to another page, e.g.: does the query on one page and pulls these values on another page?
– MagicHat
that, I want to pull the query value, but sort the result, without having to create another query
– Luann Sousa
I believe that you will store the returned data on select initial in a array.. then you can use some of those functions
– rLinhares
So I gave a read on these functions, but I believe I’ve missed the syntax several times because I couldn’t apply in my code, can you give me an example?
– Luann Sousa