yrrahxob Posted October 22, 2003 Share Posted October 22, 2003 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, t1.issue_name, t2.status_desc, t1.user_id, t1.assigned_to, t1.assigned_to_orig, t1.modified_by, t1.interested_party1_id, t1.interested_party2_id, t1.interested_party3_id, t1.interested_party4_id, t1.interested_party5_id FROM mhi_issues AS t1, mhi_statuses AS t2, mhi_users AS t3 WHERE 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\"; Link to comment https://forums.phpfreaks.com/topic/1208-problem-with-sorting-in-a-query/ Share on other sites More sharing options...
effigy Posted October 22, 2003 Share Posted October 22, 2003 what are the links passing into $sort_field? echo it out to be sure it is beind passed correctly. Link to comment https://forums.phpfreaks.com/topic/1208-problem-with-sorting-in-a-query/#findComment-4041 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.