我想建立一个自定义的php页面,该页面显示了wp的注册用户,从wp保存的数据是序列化数据,显示时出现问题。顺便说一句,我正在使用联系表7数据库插件。
我一直在获取explode()期望参数为字符串,并且在第10行出现错误。
<?php
//connect database
$conn=new mysqli("localhost","root","","testsaja2");
//call a field from table
$sql= "select form_value from wp_db7_forms";
$result=mysqli_query($conn,$sql);
while($string=mysqli_fetch_array($result));
$explode = explode(PHP_EOL, $string);
foreach ($explode as $line) {
?>
<?php
foreach (unserialize($line) as $item => $value){
?>
<tr>
<td><b><?php echo $item . ": ";?></b></td>
<td><?php if ($value == 'email'){
foreach ($value as $data) {
echo $data ;
}
}
else {
echo $value;
}
?> </td>
</tr>
<br>
<?php } ?>
</table>
<?php } ?>
答案 0 :(得分:0)
对此进行修改。
<?php
//connect database
$conn=new mysqli("localhost","root","","testsaja2");
//call a field from table
$sql= "select form_value from wp_db7_forms";
$result=mysqli_query($conn,$sql);
while($string=mysqli_fetch_array($result)){
$unserialize = unserialize($string['form_value']);
foreach ($unserialize as $item => $value){
?>
<tr>
<td><b><?php echo $item . ": ";?></b></td>
<td><?php echo $value; ?> </td>
</tr>
<?php
} }?>
</table>