Change type of SQL query

0

I have a table that shows the results of mysql through a query, but I would like to be able to change the type of query. I leave you a simple example.

$sql = 'SELECT * FROM avisos ORDER BY fecha DESC';

I need to use a button (or something similar) to change the type of query through a function

$sql = 'SELECT * FROM avisos WHERE tecnico="Manu" ORDER BY fecha DESC';
    
asked by Tefef 24.01.2018 в 13:47
source

1 answer

1

You should send a variable that should then be caught in the example query

http://tupagina.com?order=asc

You must catch the variable order and do this

$order = $_GET['order'];    
$sql = 'SELECT * FROM avisos ORDER BY fecha '.$order;
    
answered by 24.01.2018 / 14:15
source