title: Add data into two table connected with id
body: <p>Hi here I have this code to insert data to mysql database into table <code>radnici</code> :</p>
  
  <pre><code> try {        
                  $STH = $db-&gt;prepare("INSERT INTO radnici (ime_prezime, jmbg, grad, ulica, posta, telefon, uloga, email, user_id) VALUES (:1,:2,:3,:4,:5,:6,:7,:8,:9)");
  
                  $STH-&gt;bindParam(':1', $_POST['ime']);
                  $STH-&gt;bindParam(':2', $_POST['jmbg']);
                  $STH-&gt;bindParam(':3', $_POST['grad']);
                  $STH-&gt;bindParam(':4', $_POST['ulica']);
                  $STH-&gt;bindParam(':5', $_POST['posta']);
                  $STH-&gt;bindParam(':6', $_POST['telefon']);
                  $STH-&gt;bindParam(':7', $_POST['pozicija']);
                  $STH-&gt;bindParam(':8', $_POST['email']);
                  $STH-&gt;bindParam(':9', $user_id);
  
  //HERE I NEED TO INSERT DATA TO TABLE WORKHOURS BUT CONNECTED WITH JUST ADDEDED ID
  //SO here I NEED query something like this // INSERT INTO radnici (ID, ID_radnici, ime_prezime, jmbg,... here ID_radnici is =with ID from table radnici of added data
  
  
                  $STH-&gt;execute();
  
              } catch (PDOException $e) {
                  echo $e-&gt;getMessage();
              }
              echo "&lt;p&gt;Data submitted successfully&lt;/p&gt;";
  </code></pre>
  
  <p>So now when I add this I need to add into this table <code>workhours</code> data but connected with ID with just added data...</p>
  
  <p>so in second table I have: <code>ID, ID_radnici (here I must add ID_radnici same value as ID on table radnici), value, user_id</code></p>
  
  <p><strong>I write this but DONT work: 
  UPDATE:</strong></p>
  
  <pre><code> try {        
                  $STH = $db-&gt;prepare("INSERT INTO radnici (ime_prezime, jmbg, grad, ulica, posta, telefon, uloga, email, user_id) VALUES (:1,:2,:3,:4,:5,:6,:7,:8,:9)");
  
                  $STH-&gt;bindParam(':1', $_POST['ime']);
                  $STH-&gt;bindParam(':2', $_POST['jmbg']);
                  $STH-&gt;bindParam(':3', $_POST['grad']);
                  $STH-&gt;bindParam(':4', $_POST['ulica']);
                  $STH-&gt;bindParam(':5', $_POST['posta']);
                  $STH-&gt;bindParam(':6', $_POST['telefon']);
                  $STH-&gt;bindParam(':7', $_POST['pozicija']);
                  $STH-&gt;bindParam(':8', $_POST['email']);
                  $STH-&gt;bindParam(':9', $user_id);
  
                  $orderID = $db -&gt; lastInsertId();
  
     $STH1 = $db-&gt;prepare("INSERT INTO workhours (ID_radnika) values($orderID)");  // where $value is the value you want to insert...
     $STH-&gt;execute();
        $STH1-&gt;execute();
  
  
  
  
  
  
              } catch (PDOException $e) {
                  echo $e-&gt;getMessage();
          }
          echo "&lt;p&gt;Data submitted successfully&lt;/p&gt;";
  </code></pre>