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 8031523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:07:32+00:00 2026-06-05T01:07:32+00:00

I need help on how to get/display some informations from DB (MySQl) My current

  • 0

I need help on how to get/display some informations from DB (MySQl)

My current table looks like this:

id | title | level | start_afterID | days | 

1  |   A   |   0   |       0       |   7  |
2  |   B   |   1   |       1       |   5  |
3  |   C   |   1   |       2       |   3  |
4  |   D   |   1   |       3       |   2  |
5  |   E   |   1   |       4       |   2  |
6  |   F   |   1   |       3       |   6  |

Level ‘0’ means that this job will start first and start day and time is in other table ($config_start)

All others entry with level = 1 don’t have fixed start, just id of job (start_afterID) after which they start.

Also every job will last in number of days from DAYS field.

In this table job with ID 6 (title F) must start after jobID 3 – And that start time is something like:

$config_start + jobID 3 + jobID 2;

$end of this job is:

$config_start + jobID 3 + jobID 2 + 6;

At the end, I will need to display all jobs from DB in incoming order.

I tried my best with this, but i can’t figure how to check all parent levels and calculate it.
Also, I can create new administration for this and maybe there is a better way of inserting new jobs ?

THANKS for any help on this,

  • 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-06-05T01:07:34+00:00Added an answer on June 5, 2026 at 1:07 am

    First of all, I advise you to rethink the level column – IIUC this is only a boolea, telling you wether this is a job root or not – this information is also prsent in start_afterID being 0.

    Now calculating the start and end times is a non-trivial job, that requires lots of DB avvess, so I advise you to create a second table with id|startday|endday and move the calculation logic in a way, that this (essentially cache) table is updated on job change, leaving you with a fast query path for normal operations.

    To calculate the contents of this timing table, you would do something like

    function docalc($after,$startday) {
    
        $sql="SELECT * FROM tablename WHERE start_afterID=$after";
    
        //Run the query, this depends on your framework used
    
        //Pseudocode from here - again depends on your framework
        foreach ($row) {
            $id=$row['id'];
            $endday=$startday+$row['days']; //This will not be a simple addition, depending on your data types
    
            //Adapt the following to your data types
            $sql="REPLACE INTO timingcache SET id=$id, startday=$startday, endday=$endday";
            //Run the query - depends on your framework
    
            docalc($id,$endday);
    
        } //for each row
    
    }
    
    
    //this assumes $config_start is set correctly
    docalc(0,$config_start);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help optimizing a MySQL query or table When I run this
I need some help trying to get floats to display properly in IE. IE
I need your help with display of some comma separated enteries from my database.
I need help to get a response when I click on an Item from
I need help regarding JOIN tables to get category name & author name from
i got some problem and need help .. my plan : 1. get ip
I need a little help here: I get a file from an HTML upload
I need some help setting up a PHP array. I get a little lost
I am a pretty good applescripter, and would like some help with this. I
I have this strange problem I need some help with. This menu code goes

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.