Jump to content

Recommended Posts

Hi folks,

I have a table 'names' with one column 'name'.

It has 10,000 names in it.

 

I'd like to separate these 10,000 names into groups of 3 names and 1 remaining name, that is 3,333 groups of 3 with 1 leftover.

 

I'd at first thought this would be simple to accomplish but alas not only can I not do it, I've had no luck at any other forum.

 

Does anybody have any ideas please.

 

Regards

 

Taffd

Link to comment
https://forums.phpfreaks.com/topic/100300-bet-you-cant-solve-this-one/
Share on other sites

In detail then -

 

I'm trying to set up a new system for electing leaders.

 

The electorate are divided into groups of 3.

 

Each group then elects 1 of the 3 to represent them at the next level.

 

Thus from 10,000 names, I want 3,333 groups of 3 names and 1 remaining name who will advance automatically to the next level.

 

The second level will thus have 3,334 names. Again, I will want to organise them into 1,111 groups of 3 and have 1 remaining.

 

I'll continue the process until I arrive at the required number of leaders, somewhere between 14 and 100.

 

At the final level, I'll adjust the numbers in the groups so there's no remainder.

 

There are no time constraints for this process, it's a back-end operation that will happen once a year.

 

The whole exercise is a personal project that a friend and I are working on, an idealised community, with a web-based governance.

make 2 tables

the main table sumfin like

TABLE
   id integer
   name varchar
   group integer

 

and a groups table, sumfin like

TABLE
  id integer
  lvl integer
  max integer

 

now u can assign how many ppl shud go into a group with some php coding.

it's not as u make it out, where u divide all the names into seperate dbs

but u add more info to the db so u can seperate different records.

 

 

 

OK,

Supposing I had a table:-

 

groupID, name1, name2, name3

 

How do I go about taking 3 people from the names table, insert them into the above group table and then repeat the process, taking 3 different names etc. and so on until there is only one remaining name.

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.