title: how to pass the last inserted id in the url in same page
body: <pre><code>&lt;h2&gt;&lt;a style="margin-left:370px;" class="btnAction" href="&lt;?php echo getResult.php?id=mysqli_insert_id($link)"&gt;&lt;span&gt;Click to view results &lt;/span&gt;&lt;/a&gt;&lt;br/&gt; &lt;br/&gt; 
  
  
  &lt;?php 
            if(!empty($_POST))
            { //here post values are inserted
              $userId     = $_SESSION['user_id']; 
              $setId      = $_SESSION['rand_set'];
              $testDate   = date( 'Y-m-d H:i:s' );
              $timeSpent  = (!empty($_POST['timeTaken']))?$_POST['timeTaken']:$_SESSION['time']; 
              $userTable  = "user_tests";
              $fields = array("user_id", "set_id", "test_taken", "time_spent", "score", "status");
              $values = array($userId, $setId, $testDate, $timeSpent, $rightAnswer, "1");
              $result = insert($userTable, $fields, $values); 
              $lastId = mysqli_insert_id($link);//want to pass this id in the url
             }
             ?&gt;
  </code></pre>
  
  <p>I'm trying to pass the $lastId that is last inserted id via url, but im not getting the id it's just printed in the url e.g., <code>(getResult.php?id=mysqli_insert_id($link))</code>
  can anyone help me </p>