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