Order by title problem

admin

Administrator
Staff member
I have a linking table (tbAppLSubApp) that pairs Applications with SubApplications. On my website, an application ($fkApp) is passed as a query string, and then I use it ($fkApp) to pull up a list of SubApps ($fkSubApp) from the linking table and then for each SubApp, I print out its title ($Title) and description ($Description) from the SubApp table (tbSubApp). The problem is that, because the SubApps are pulled up in a loop based on the order in the linking table, I can't seem to alphabetize them even if I put "order by Title" in the second query. Any ideas? Here is my code, in case you need more info.

Thanks!

/* use $fkApp to find all related SubApps */
$query = "select * from tbAppLSubApp where fkApp = '$fkApp'";
$mysql_result = mysql_query($query, $mysql_link);
while ($tbAppLSubApp = mysql_fetch_object($mysql_result)){
$fkSubApp = $tbAppLSubApp->fkSubApp;
/* get chosen SubApp */
$k_query = "select * from tbSubApp where pkSubApp = '$fkSubApp'";
$k_query_result = mysql_query($k_query, $mysql_link);
$k = mysql_fetch_object($k_query_result);
$pkSubApp = $k->pkSubApp;
$Title = stripslashes($k->Title);
$Description = stripslashes($k->Description);
/* print out the SubApps */
print "$Title: $Description<br>";
}
 
Back
Top