30 March 2021

Wordpress Custom Plugin Creation Code in form_data_list.php

 <?php 

//echo "hello";

global $wpdb;

global $table_prefix;

//$table = $table_prefix.'form_data';

// without using table prefix start

$table = 'form_data';

// without using table prefix end

$sql = "select * from $table";

$result = $wpdb->get_results($sql);

//print_r($result);

?>

<!DOCTYPE html>

<html>

<head>

<title>Bootstrap basic table example</title>

<meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

<style>

.table-striped>tbody>tr:nth-child(odd)>td, 

.table-striped>tbody>tr:nth-child(odd)>th {

   background-color: #C49F0F;

 }

 </style>

</head>

<body>

<div class="container ">

<table class="table table-bordered table-striped table-hover table-responsive">

  <tr>

      <th>ID</th>

      <th>Name</th>

      <th>Email</th>

      <th>Phone</th>

      <th>Subject</th>

      <th>Messhae</th>

  </tr>

  <?php 

    $i=1;

   foreach($result as $list){

  ?>

  <tr>

      <td><?php echo $i++; ?></td>

      <td><?php echo $list->name; ?></td>

      <td><?php echo "indra422@gmail.com"; ?></td>

      <td><?php echo "8210440537"; ?></td>

      <td><?php echo "test subject"; ?></td>

      <td><?php echo "test message"; ?></td>

  </tr>

<?php } ?>

</table>

</div><br /><br />

</body>

</html>