Jump to content


Problem with sorting in a query

  • Please log in to reply
1 reply to this topic

#1 yrrahxob

  • Members
  • Pip
  • Newbie
  • 9 posts
  • LocationKaty, Texas

Posted 22 October 2003 - 02:40 PM

Ok here is my problem. I have a query where I read a table T1 named
MHI_ISSUES and 9 of the columns in the table contain a user id which
can be from 1 to 3 digits. I also have another tabe T3 named MHI_USERS
that I use to get the user name for each of the columns in the first table
and then display them in a table on the screen. The headers on each
of the columns is a link refreshing the page and sending a sort by number
telling the query to sort by this column. When I do this, it sorts by
the user_id number but I want it to sort by the user name. Does anyone
know of a way to do this? I have my query shown below. Any help
would be greatly appreciated.

$qry=\"SELECT t1.issue_id,
mhi_issues AS t1,
mhi_statuses AS t2,
mhi_users AS t3
t1.status_id = t2.status_id AND (
t1.user_id = \'$user\' OR // $user is the 1 to 3 digit user_id number
t1.assigned_to = \'$user\' OR
t1.assigned_to_orig = \'$user\' OR
t1.interested_party1_id = \'$user\' OR
t1.interested_party2_id = \'$user\' OR
t1.interested_party3_id = \'$user\' OR
t1.interested_party4_id = \'$user\' OR
t1.interested_party5_id = \'$user\' OR
t1.modified_by = \'$user\') AND
t3.user_name = \'$user_name\' // $user_name is the user_name field which I get when the page is loaded
ORDER BY $sort_field
LIMIT $seek_pos, $limit_return\";
Harry R. Box
[br]We must all hang together or we shall surely hang separately.
[br]A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear Arms, shall not be infringed."

#2 effigy

  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 22 October 2003 - 04:12 PM

what are the links passing into $sort_field? echo it out to be sure it is beind passed correctly.
Regexp | Unicode Article | Letter Database

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users