stumped by "order by"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



My problem is I can't seem to find the right place to
put an "order by" clause in my statement.  

I have  this select statement:

$query_rsVJ = " SELECT Jobs.PostStart,
Jobs.JobID,Jobs.JobTitle, 
Jobs.City, Ind.Categories, VendorSignUp.CompanyName, 
US.States, Term.Tax FROM Jobs 
INNER JOIN Ind ON (Jobs.Industry = Ind.CIDs)
INNER JOIN US ON (Jobs.State = US.SID)
INNER JOIN SignUp ON (Jobs.VID = SignUp.VID)
INNER JOIN Term ON (Jobs.Tax = Term.TID)";

But then I also have a dynamic where clause that is
based on what values the user has chosen:

if(!empty($s_Ind)) $aWHERE[] = "Jobs.Industry IN
($s_Ind)" ;
if(!empty($s_State)) $aWHERE[] = "Jobs.State IN
($s_State)";
if(!empty($s_TType)) $aWHERE[] = "Jobs.Term IN
($s_TType)";
if(!empty($JTitle)) $aWHERE[] = "Jobs.Title LIKE
'%$JTitle%'";
if(!empty($City)) $aWHERE[] = "Jobs.City LIKE
'%$City%'";
if(!empty($Days)) $aWHERE[] = "Jobs.Post >=
DATE_SUB(CurDate(), Interval ($Days) DAY)";

When the sql is submitted the results come back (in
columns of course) Then the user can click the column
head and sort  by that column.

$orderParam_rsVJ = "City";
if (isset($_GET['order_rsVJ'])) {
  $orderParam_rsVJ = (get_magic_quotes_gpc()) ?
$_GET['order_rsVJ'] : addslashes($_GET['order_rsVJ']);
}

I just have had no luck putting in 
order by "$orderParam_rsVJ in the current statement
(above).

If I put it in the select statement , the it's out of
place with the where clause.
If I put it at the end of the where clause, obviously
it is not seen. 
Any ideas how I can set this up correctly ?

Stuart

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux