title: How can i fetch data from my requests table and put it in users table
body: <p>I'm making a user registration request system.</p>
  
  <p>Can you help me convert the accept.php file to mysqli? Because i'm using mysqli and this one uses pdo.</p>
  
  <p>This is my code for the user request.</p>
  
  <pre><code>&lt;?php
           $query = "select * from `requests`;";
           if(count(fetchAll($query))&gt;0){
               foreach(fetchAll($query) as $row){
                   ?&gt;
  
  
               &lt;h1 class="jumbotron-heading"&gt;&lt;?php echo $row['name'] ?&gt;&lt;/h1&gt;
  
                 &lt;p&gt;
                   &lt;a href="accept.php?id=&lt;?php echo $row['id'] ?&gt;" class="btn btn-primary my-2"&gt;Accept&lt;/a&gt;
                   &lt;a href="reject.php?id=&lt;?php echo $row['id'] ?&gt;" class="btn btn-secondary my-2"&gt;Reject&lt;/a&gt;
                 &lt;/p&gt;
               &lt;small&gt;&lt;i&gt;&lt;?php echo $row['DateRegister'] ?&gt;&lt;/i&gt;&lt;/small&gt;
       &lt;?php
  </code></pre>
  
  <hr>
  
  <p>my code in accept.php</p>
  
  <pre><code>&lt;?php
  include "core/init.php";
  include "functions.php";
  
          $id = $_GET['id'];
          if(count(fetchAll($sql)) &gt; 0){
          foreach(fetchAll($sql) as $row){
          $username = $_POST['username'];
          $password = $_POST['password'];
          $unitid = $_POST['unitid'];
          $worknum = $_POST['worknum'];
          $homenum = $_POST['homenum'];
          $userlevel =$_POST['usertype'];
          $empname = $_POST['empname'];
          $position = $_POST['position'];
          $comment = $_POST['comment'];
          $sql = "INSERT INTO users (id,username, password, usertype,DateRegister, name, unit_id, phone_work, phone_home, comment, position,LastUpdated) VALUES (NULL,'$username','$password','$userlevel','$currentdate','$empname','$unit_id','$worknum','$homenum','$comment','$position','$currentdate,$currentTime')";
      }
      $sql .= "DELETE FROM `requests` WHERE `requests`.`id` = '$id';";
      if(performQuery($sql)){
          echo "Account has been accepted.";
      }else{
          echo "Unknown error occured. Please try again.";
      }
  }else{
      echo "Error occured.";
  }
  }
  </code></pre>
  
  <hr>
  
  <p>My functions.php</p>
  
  <pre><code>&lt;?php
  define('DBINFO','mysql:host=localhost;dbname=arenew');
  define('DBUSER','root');
  define('DBPASS','');
  
  function performQuery($query){
      $con = new PDO(DBINFO,DBUSER,DBPASS);
      $stmt = $con-&gt;prepare($query);
      if($stmt-&gt;execute()){
          return true;
      }else{
          return false;
      }
  }
  
  function fetchAll($query){
      $con = new PDO(DBINFO, DBUSER, DBPASS);
      $stmt = $con-&gt;query($query);
      return $stmt-&gt;fetchAll();
  }
  
  ?&gt;
  </code></pre>
  
  <p>After clicking accept, it says error or undefined index. </p>