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.City, Ind.Categories, VendorSignUp.CompanyName, 
US.States, Term.Tax FROM Jobs 
INNER JOIN Ind ON (Jobs.Industry = Ind.CIDs)
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
if(!empty($s_TType)) $aWHERE[] = "Jobs.Term IN
if(!empty($JTitle)) $aWHERE[] = "Jobs.Title LIKE
if(!empty($City)) $aWHERE[] = "Jobs.City LIKE
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

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 ?


PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to