djfox Posted October 29, 2008 Share Posted October 29, 2008 Here`s my code: <?php $res = mysql_query("SELECT bought FROM userdata WHERE id='$logged'"); $a = mysql_fetch_row($res); $it = explode(",", $a[0]); foreach ($it as $th) { $res2 = mysql_query("SELECT id, shortname, type, name, cost FROM clothing WHERE id='$th'"); $b = mysql_fetch_row($res2); mysql_free_result($res2); echo "$b[3] <br>"; } ?> I want the end results to be listed in the order of the id numbers (listed in both as $b[0] and $th). How do I tell my code to list the results in numerical order? Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted October 29, 2008 Share Posted October 29, 2008 Sort the array first? see: sort() Quote Link to comment Share on other sites More sharing options...
djfox Posted October 29, 2008 Author Share Posted October 29, 2008 It doesn`t work that way for this, I already tried. Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted October 29, 2008 Share Posted October 29, 2008 Sorry, were you replying to me before the edit or after? I really didn't look closely at your code at first thought I caught the edit before you saw. Quote Link to comment Share on other sites More sharing options...
djfox Posted October 29, 2008 Author Share Posted October 29, 2008 I replied before the edit. Ok, thanks, I`ll give it a try. Quote Link to comment 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.