Jump to content

2d Array Help


richie19rich77

Recommended Posts

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  Points
1                  5
2                  8
3                  1
4                  2
5                  11

I 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_ID

Fixtures_ID  Points
1                  1
2                  2
3                  5
4                  8
5                  11

But it should look like:

Fixtures_ID  Points
3                  1
4                  2
1                  5
2                  8
5                  11

So how would I creare a 2d array, and input into the 2d array within a loop of the Fixtures_ID,

I would like to do

For.......
  $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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.