使用ORDER BY ID DESC和[关闭]

how can i use right code for using ORDER BY id DESC and WHERE

$sel = "SELECT * FROM items where portfolio_id=".$_GET['folio_id']."ORDER BY id DESC";

Add a space here as shown.

$sel = "SELECT * FROM items where portfolio_id=".$_GET['folio_id']." ORDER BY id DESC";
                                                                ----^

Also, don't pass your parameters like $_GET or $_POST directly into the SQL query as it will definitely lead to SQL Injection Attacks. Filter those parameters or make use of Prepared Statements.

add a space before 'ORDER' at least

 $sel = "SELECT * FROM items where portfolio_id=".$_GET['folio_id']." ORDER BY id DESC";

You need provide space before ORDER BY

$sel = "SELECT * FROM items where portfolio_id=".$_GET['folio_id']." ORDER BY id DESC";

Simply Use this :

$sel = "SELECT * FROM items where portfolio_id ='$_GET[folio_id]' ORDER BY id DESC";