i want to get array of input from user and store it to database on the same page is it possible???
Yes
this code is correct or wrong please help me..
It's wrong on both logic and syntax parts
PHP does not work the way you think it does.
<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];
?>
}
This will only execute javascript function with invalid content (that is username you queried from database) when you click show button. The php script will be run at time of page generation. For it to execute on server you would have to do rpc (search ajax) and write handlers for both server and client.
To answer the question, array input from HTML form may be gotten simply as
<input type="text" name="name[0]">
<input type="text" name="name[1]">
<input type="text" name="name[2]">
However for this to work you would have to have client-side script which will create new inputs every time you want add new user (and it's bad idea anyway).
<?php
$mysqli=new mysqli("localhost","root","hiitisme","data");
$name=$mysqli->escape_string($_POST['name']);
$sql="INSER INTO user(name)VALUES ('$name')";
$mysqli->query($sql);
?>
Now you need to fix this to actually store array, escaping should be per item, and array should be serialized into VALUES compatible format (that is 'A','B','C'
$name = implode("','"array_map($mysqli->escape_string, $_POST['name']));
$sql = "INSERT INTO user(name) VALUES ('$name')";
You should also check if the page is actually generated (that is it should show add password) or it should store data (simply check if $_POST['name'] exists...
array of inputyou don't mean an HTML Input Array (Inputs with same name but used for multiple values), do you? And also you're missing a$row=$result->fetch_array().