Jump to content

Order one, then another, then another


tibberous

Recommended Posts

I have a table with several types in an enum, lets say Stores, Offices and Restaurants.

 

I can order by desc, and get Offices, Restaurants, Stores. I can order by asc and get Stores, Restaurants, Offices.

 

Lets say though I wanted Restaurants, Stores, Offices. Is there a way I can say, return X, then Y, then Z?

Link to comment
Share on other sites

 

Yep use something like this

 

<tr> 
<td style="width: 279px"> 
<table class="top"> 
<tr> 
<td style="width: 95px" class="style10"><strong>Resturant</strong></td> 
<td style="width: 93px" class="style10"><strong>Stores</strong> </td>
<td style="width: 93px" class="style10"><strong>Officies</strong></td>
</tr> 
<? 
mysql_connect("***","**","**");//database connection 
mysql_select_db("legion"); 
                 
$order = "SELECT * FROM tbl_name ORDER BY RESTURANT";  // Where I put Resturant you can change that to stories, offices etc.. 
$result = mysql_query($order);   
while($data = mysql_fetch_row($result)){ 
  echo("<tr><td>$data[0]</td><td>$data[6]</td><td>$data[7]</td><td>$data[1]</td></tr>");  
} 
?> 

 

Above where you see the <Td>$data[0]</td>

where you see the number in the brackets, change that to the column number of whatever columns in your my-sql db

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.