Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5939313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:48:37+00:00 2026-05-22T15:48:37+00:00

When the customers submit the orders on the website.. staffs can view the pending

  • 0

When the customers submit the orders on the website.. staffs can view the pending orders (pull data from mysql) on the admin backend but I want the pending orders to split into two team.

Example

We have received 21 pending orders.

There are 11 staffs.

Team 1: 5 staffs

Team 2: 6 staffs

Team 1 can view 11 orders and Team 2 can view 10

Sometime I might get 100 orders every hour – PHP should determine to split half of the pending orders into two teams (dynamically)…

Should the team_id set on the order table? Eg: tbl_orders.team_id = 2 when users submit the orders? .. but what if not enough staffs logged in team 1 or 2

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:48:38+00:00Added an answer on May 22, 2026 at 3:48 pm

    You have 2 ways.

    First (dynamic)

    First of all you count all the pendings:

    SELECT COUNT(*) FROM pending;
    

    Then you show the first half to team 1:

    $half = round($count/2);
    SELECT * FROM pending ORDER BY id DESC LIMIT $half;
    

    Team 2 gets:

    SELECT * FROM pending ORDER BY id DESC LIMIT $half,$half;
    

    If you have more team you just need to divide for the total number of teams insted by 2.

    Second option (fixed)

    When pending are inserted you associate them with a team. But you have to add another field to your table.

    Let’s say you have a field team TINYINT(1) UNSIGNED.

    When the next pending is placed you check the last team inserted with this:

     SELECT team FROM pending ORDER BY id DESC LIMIT 1;
    

    Let’s say you have a config where is stored your number of teams:

     $totalTeamsAvailable = 2;
    

    With the value that you have select with the query you do:

     $nextTeam = (++$teamFromSql % $TotalTeamsAvailable) + 1;
    

    Now you have the team that can be associated with this pending. Of course you add it with

     INSERT INTO pending (data,team) VALUES (,$nextTeam);
    

    This second solution may suffer of race condition. (IE: 2 pending placed at nearly the same istant may be associated with the same team, but I believe this will not hurt at all )

    Addedum

    To count the team that recently have done something you have 2 ways:

    • You need a table teams where you store the last login data of the staff.
    • Store each actions that each teams have done (for example team 1 approved and sent order pending #2) with a data (maybe you have already this table)

    At this point it’s easy to select the number of team with a recently activity.
    Using the table team you just need to do a:

    $teamWithRecentlyActivity = SELECT COUNT(*) FROM teams WHERE lastLogin > (time() - (60*60*24));   
    //> This select all teams within 1 day from last login
    

    Having this number you can split all the pending you need with:

    $pendingPerTeam = round($totalPendings / $teamWithRecentlyActivity);
    

    And use this offset within my first solution

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wish to update MYSQL data using text instead of using submit button. Admin
Order Page: On this page, customers can choose to add business card orders with
I give customers javscript code that adds a widget to their website. Currently I
I have a form that customers fill in with personal data and also makes
My Customer model has many Orders. I am collecting the data for multiple Orders
I'm making an online form for customers and now adding a submit button which
In my application, i have: a table storing customers' orders, and a table storing
customers does not want to allow user to use back or forward button. Just
Customers Holidays id | name customer_id | start | end ---+------ ------------+--------+------ 1 |
For some of the customers that we develop software for, we are required to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.