Jump to content

[SOLVED] Listing foreach() list in a certain order?


djfox

Recommended Posts

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?

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.