richie19rich77 Posted November 12, 2006 Share Posted November 12, 2006 Hi All,I am creating a sports league / results website. I have a field called "Fixtures_ID" this field contains 14 items that varey from 1 to 14. I also have a function that works out the number of points each team has.Now I am first doing a selct statement on the Fixtures_ID getting all teams that are in the 1st division, this gives me the fixtureID for each team.But I want the league table to be sorted by number of points, now I am trying to create a 2d array that contains the number of points and fixtureID, the items must say together as they are used for querying different items.so array should look like:Fixtures_ID Points1 52 83 14 25 11I can loop round on the select statement to put the fixtures_ID into an array, but I could also get the points the same way, but as soon as I sort the points array, it loses any connection to the Fixtures_IDFixtures_ID Points1 12 23 54 85 11But it should look like:Fixtures_ID Points3 14 21 52 85 11So how would I creare a 2d array, and input into the 2d array within a loop of the Fixtures_ID,I would like to doFor....... $array[$x][$y] = $FixturesID,$Points$x looping on the fixtures and $y looping on the points.Hope that makes sense.Thanks Link to comment https://forums.phpfreaks.com/topic/27028-2d-array-help/ Share on other sites More sharing options...
doni49 Posted November 12, 2006 Share Posted November 12, 2006 http://www.phpfreaks.com/forums/index.php/topic,114453.0.html Link to comment https://forums.phpfreaks.com/topic/27028-2d-array-help/#findComment-123617 Share on other sites More sharing options...
sasa Posted November 12, 2006 Share Posted November 12, 2006 look natsort() function Link to comment https://forums.phpfreaks.com/topic/27028-2d-array-help/#findComment-123622 Share on other sites More sharing options...
richie19rich77 Posted November 12, 2006 Author Share Posted November 12, 2006 Thank you "doni49", that link worked a treat.so basic and so easy.[code]$out = array ();for ($x = 0; $x < $num_rows ; $x++) { $out[] = array ($x,$x);}[/code]Thanks Link to comment https://forums.phpfreaks.com/topic/27028-2d-array-help/#findComment-123646 Share on other sites More sharing options...
doni49 Posted November 13, 2006 Share Posted November 13, 2006 Well I didn't do anything special. I just knew that I had read that thread recently and knew what to search for. Link to comment https://forums.phpfreaks.com/topic/27028-2d-array-help/#findComment-123670 Share on other sites More sharing options...
Psycho Posted November 13, 2006 Share Posted November 13, 2006 Is there a reason you just don't sort the records in your select statement? Link to comment https://forums.phpfreaks.com/topic/27028-2d-array-help/#findComment-123792 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.