Need help with PHP ORDER BY code?

boxcarracer8792

New Member
I want to put ORDER BY on the code below, but I tried putting it in ever possible spot, and it gives me errors. Could somebody translate it to the proper code, I want it to be ordered like this<br />
<br />
ORDER BY id, sticky DESC<br />
<br />
This is my code<br />
<br />
$result = mysql_query('SELECT id,name,creator FROM website_forums_threads WHERE section='.$HTTP_GET_VARS['id']);<br />
<br />
<br />
Thanks, I will give you best answer if I can figure out how lol |<br />
 

shibs

New Member
$result = mysql_query('SELECT id,name,creator FROM website_forums_threads WHERE section='.$HTTP_GET_VARS['id'].' order by id DESC' );
 

Maxood

New Member
You need to concatenate the rest of the SQL inline query with the ORDER BY clause.All you have to do is to use a proper cancatenation operator.
Hers is the correct code
$result = mysql_query('SELECT id,name,creator FROM website_forums_threads WHERE section='.$HTTP_GET_VARS['id'].'ORDER BY id, sticky DESC');

Hope it helps
 
Top