Jump to content

Bet you can't solve this one


Taffd

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.

 

 

 

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.