tibberous Posted September 7, 2008 Share Posted September 7, 2008 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 More sharing options...
ChompGator Posted September 7, 2008 Share Posted September 7, 2008 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 https://forums.phpfreaks.com/topic/123173-order-one-then-another-then-another/#findComment-636160 Share on other sites More sharing options...
Mchl Posted September 7, 2008 Share Posted September 7, 2008 I don;t believe this query will work... RESTAURANT is not a column name here... Here's alink PFMaBiSmAd showed us yesterday. http://www.eklekt.com/tutorials/mysql Link to comment https://forums.phpfreaks.com/topic/123173-order-one-then-another-then-another/#findComment-636161 Share on other sites More sharing options...
ChompGator Posted September 7, 2008 Share Posted September 7, 2008 Oh, Yep Mchl is right... My script will ONLY work if you are retrieving data from an SQL database, if you just have a table with data on a webpage - this query wont work he is right! Thanks! Link to comment https://forums.phpfreaks.com/topic/123173-order-one-then-another-then-another/#findComment-636167 Share on other sites More sharing options...
tibberous Posted September 8, 2008 Author Share Posted September 8, 2008 I don;t believe this query will work... RESTAURANT is not a column name here... Here's alink PFMaBiSmAd showed us yesterday. http://www.eklekt.com/tutorials/mysql Awesome! Link to comment https://forums.phpfreaks.com/topic/123173-order-one-then-another-then-another/#findComment-636231 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.