title: How do I update parent records in mysql using php
body: <p>i've been working on this mlm (pyramid) project, I am done with all the visual pyramid system display etc. now I need to update all parent records of the client. here's my database table and binary tree of users :</p>
  
  <p><img src="https://i.stack.imgur.com/O2kUW.jpg" alt="Database table and binary tree display"></p>
  
  <p>As you can see i have id and parentid, now when i add new user under an id. i need to update all parents' left / right and commission. I am finding it very complicated.. cos I can't just update 1 row.. i need to update all its parent rows, may be doing loop or w.e. If anyone has done this before please help me how can i do this.</p>