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
https://forums.phpfreaks.com/topic/123173-order-one-then-another-then-another/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.