GremlinP1R Posted October 10, 2006 Share Posted October 10, 2006 Hi ThereI have now with a lot of effort and a huge script got to a point I just have to sort some data.But now I cant use the Order by in the mysql_query as the number it sould be sorted by is after all the proceses. I have got a $d_id that = to a 2digit number. How do I sort information only using the page and not the database?using $row = mysql_fetch_array() to display all data on page!Please help if possible. Thanx Quote Link to comment https://forums.phpfreaks.com/topic/23575-sorting-data-on-page/ Share on other sites More sharing options...
Daniel0 Posted October 10, 2006 Share Posted October 10, 2006 Why can't you use order? Could you show us the query? Quote Link to comment https://forums.phpfreaks.com/topic/23575-sorting-data-on-page/#findComment-107016 Share on other sites More sharing options...
GremlinP1R Posted October 10, 2006 Author Share Posted October 10, 2006 thats the problem it not in a query, the data get puled from the database get changed and everything and then the digit only exist with what it has to be orderd by, The query's order are from the database. Quote Link to comment https://forums.phpfreaks.com/topic/23575-sorting-data-on-page/#findComment-107022 Share on other sites More sharing options...
Daniel0 Posted October 10, 2006 Share Posted October 10, 2006 [code]SELECT * FROM stuff ORDER BY order ASC;[/code]Or if you got a table for the orders then something like this:[code]SELECT s.*,o.* FROM stuff AS s LEFT JOIN orders AS o ON s.id=o.oid ORDER BY o.order ASC;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23575-sorting-data-on-page/#findComment-107031 Share on other sites More sharing options...
GremlinP1R Posted October 10, 2006 Author Share Posted October 10, 2006 hehe Daniel where not on the same wave lenght here, wait let me try again.Okay I'm using a search function to search the data base for a sertian part of a 13digit numberif (isset($_POST['Get'])){ if ($select == Num32){$result = mysql_query("SELECT * FROM table WHERE row LIKE '__32_________' ORDER BY row ASC ") or die();} elseif ($select == Num27){$result = mysql_query("SELECT * FROM table WHERE row LIKE '__27_________' ORDER BY row ASC ") or die();}then after that I'm getting it to show but with a twist that digit is a 13digit numer searching using position 3 and 4 op the number. There after I I put it on the page.// keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )){ // Print out the contents of each row into a table echo "<form action='individualsdetaiils.php' method='post'>"; $ref = $row['ID']; $bid = $row['idno']; if ($bid != 0){ $d_id = $bid{4}.$bid{5}; $m_id = $bid{2}.$bid{3}; if ($m_id == 1){$m_id = one;} elseif ($m_id == 2){$m_id = two;} elseif ($m_id == 3){$m_id = three;} elseif ($m_id == 4){$m_id = four;} echo "</td><td>"; echo $row['Names']; echo "</td><td>"; echo "$d_id $m_id"; echo "</td><td>";Now what I want to do is sort by $d_id that is created here after the query. the $d_id is position 5 and 6 in the 13digit number. Quote Link to comment https://forums.phpfreaks.com/topic/23575-sorting-data-on-page/#findComment-107046 Share on other sites More sharing options...
GremlinP1R Posted October 10, 2006 Author Share Posted October 10, 2006 Help Someone PLEASE Quote Link to comment https://forums.phpfreaks.com/topic/23575-sorting-data-on-page/#findComment-107061 Share on other sites More sharing options...
GremlinP1R Posted October 10, 2006 Author Share Posted October 10, 2006 Just getting it back into sight Quote Link to comment https://forums.phpfreaks.com/topic/23575-sorting-data-on-page/#findComment-107110 Share on other sites More sharing options...
obsidian Posted October 10, 2006 Share Posted October 10, 2006 check out [url=http://www.php.net/array_multisort]array_multisort()[/url]. example 3 is specifically what you're after. Quote Link to comment https://forums.phpfreaks.com/topic/23575-sorting-data-on-page/#findComment-107120 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.