Questions about how to stagger a certain number of writes with similar PHP IDs

Source: Internet
Author: User
A seating chart, a student table

Seating chart:
ID Zid UserID

Student table:
UserID Cityid


Now I want to randomly write the student table students to the seating chart, seating chart Zid is a 2 digit seat number

For example, the student table has 20 students, of which 5 cities Cityid the same, 5 Cityid the same student to stagger 5 digits in the seating table Zid so, how can it be achieved?

A PHP for testing purposes to prevent the city Cityid the same student seat.

Thank you, first!


Reply to discussion (solution)

Who is the Master guide, thank you!

Stagger 5 bits is the interval between 5 and above, or the interval 4 can be?
If it is the former, then 5 students of the same Cityid will not be able to appear in the classroom of 20 people at the same time

Thank you upstairs friend reply, this is just hypothesis, classroom number may be 100 people

Who is the Master guide, thank you!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.