Jump to content

How would you do this?


paulman888888

Recommended Posts

hi;

 

I am trying to create a simple tournament script.

 

The amount of people who are in the tournamnt will change all the time so i cant use a fixed script.

 

I no i need to use lots of loops but i dont no where.

 

THIS IS THE PROBLEM!

how do the loops join together.

 

I think i need to do something like this;

 

Get the amount of player

Get the each name of a player and store in an array

Then am stuck...

Pair each one with another

then pair again but the same person

and so on untill all have played all!

 

Please Help me

Thankyou in advance

Paul Hutchinson

Link to comment
Share on other sites

Instead of describing how you think you should do, how about describing what you want the result to be? Are you just looking to get a list of people and their opponents? This is essentially a many-to-many relationship for which you'll need an intermediary table to store relations.

 

Sort of like this:

SELECT a.player_name player1, b.player_name player2
  FROM player_opponents x
  INNER JOIN players a
    ON x.player_id = a.player_id
  INNER JOIN players b
    ON x.player_id = b.player_id;

 

The player_opponents table just has two integer fields referencing a row in the players table.

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.