Show contact form 7 Wordpress data in PHP admin panel is very easy.
When a user fill up form through contact form 7 it store in wp_cf7_vdata_entry. But the data store process is little bit different than we store normally.
It store the data vertically. So we need to convert it horizontal to show in our php admin panel.
Let’s see how to change vertical table record into horizontal in PHP.
View.php
<?php
include_once 'database.php';
$result = mysqli_query($conn,"SELECT data_id,
MAX( CASE WHEN name = 'your-name' THEN value END) AS Name,
MAX( CASE WHEN name = 'your-email' THEN value END) AS Email,
MAX( CASE WHEN name = ‘tel-780‘ THEN value END) AS Phone,
MAX( CASE WHEN name = ‘your-address‘ THEN value END) AS Address
FROM wp_cf7_vdata_entry where cf7_id = 8100
GROUP BY data_id
;");
?> <!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<table class="table table-bordered">
<thead>
<tr>
<th>Sl no</th>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Address</th>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_array($result)) {
?>
<tr>
<td><?php echo $row[“date_id”]; ?></td>
<td><?php echo $row[“Name”]; ?></td>
<td><?php echo $row[“Email”]; ?></td>
<td><?php echo $row[“Phone”]; ?></td>
<td><?php echo $row[“Address”]; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</body>
</html>