i want to get array of input from user and store it to database on the same page is it possible???

```
<!doctype html>
<html>
<head>
<title>sql</title>
</head>

 <body>
 <?php
     $mysqli=new mysqli("localhost","root","hiitisme","data");
 $name=$mysqli->escape_string($_POST['name']);
 $sql="INSERT INTO user(name)VALUES ('$name')";
 $mysqli->query($sql);
 ?>
    <script type="text/javascript">
    function show() {
<?php
      $my=new mysqli("localhost","root","hiitisme","database");
      $sq="SELECT name FROM user";
      $result=$my->query($sq);
      echo $result[0];
?>
}
    </script>
<form method="post">
   <input type="text" name="name">
   <input type="submit" value="submit">
   <input type="button" value="show" onClick="show();" />
</form>
</body>
</html>

```

this code is correct or wrong please help me..