ORDER BY problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

ORDER BY problem

Post by Addos »

http://www.tyre-tyre.com/search_instructor.php?idfk=29

I have a page here where “lives in this County” is run from the following query and is highlighted in red:

Code: Select all

<?PHP  if ($row_GetTrainers['inCounty'] != $row_DisplayLocation['location'])
echo '- services this County.' ;?>		
<?PHP  if ($row_GetTrainers['inCounty'] == $row_DisplayLocation['location'])
 echo '<span class="location">'.'- lives in this County.'.'</span>' ;?>
What I need is to have any of the specific names with - lives in this County to come up first on the page. Basically I need to run something like ‘ORDER BY’ however I don’t seem to be able to do this within the constraints of the code above. Is it possible to add something to the script above so that if any of the names are returned from the database in red they will come up listed first on the page. If you check out other locations you will see a little more of what I mean.
Thanks for any help and if necessary I can post more code.
Many thanks
Brian
lettie
Forum Newbie
Posts: 15
Joined: Fri Jan 28, 2005 6:57 am

Post by lettie »

Quick solution would be to add a column to your database called lives. Enter a number in the column where if they live in the county its '1' if they service the county its '2' then 'ORDER BY' lives either ascending or descending depending on what you want.
Post Reply