我有下一个文件将数组[]存储到mysql数据库中。现在我想创建一个文件来查看存储的数据,作为信息文件......就像带有结果的表格或其他内容。
在 phpmyadmin 数据库中,我看到存储的数据为:
a:2:{i:0;s:10:"sentra b15";i:1;s:10:"sentra b13";}
感谢您的宝贵时间
index.php
<html>
<body>
<form action="insert3.php" method="post">
Firstname: <input type="text" name="firstname[]"> <br>
Firstname 2: <input type="text" name="firstname[]"> <br>
Firstname 3: <input type="text" name="firstname[]"> <br>
Firstname 4: <input type="text" name="firstname[]"> <br>
<input type="submit">
</form>
</body>
</html>
插入.php
<?php
$con=mysqli_connect("localhost","inputmultiplicad","inputmultiplicado","inputmultiplicado");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$data= $_POST['firstname'];
$values= serialize($data);
$sql="INSERT INTO input_field (firstname)
VALUES
('$values')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";
mysqli_close($con);
?>
最佳答案
这是php的结果 serialize 功能。使用unserialize 函数对其进行解码:
echo unserialize($str);
关于php - 如何读取/查看存储的数组[] mysql php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22240222/