<?php /* * Template Name: Show Form Template Page */ ?> <div class="container"> <div class="row"> <div class="col-md-12"> <form method="POST"> <table border="1"> <tr> <th>Id</th> <th>Name</th> <th>Email</th> <th>Gender</th> <th>Age</th> <th>Edit</th> <th>Delete</th> </tr> <?php global $wpdb; $table= 'wp_contact_form'; $result = $wpdb->get_results ( "SELECT * FROM $table" ); if(!empty($result)){ foreach ( $result as $print ) { //here $result is an array // $print variable is for current row ?> <tr> <td><?php echo $print->id;?></td> <td><?php echo $print->names;?></td> <td><?php echo $print->emails;?></td> <td><?php echo $print->gender;?></td> <td><?php echo $print->age;?></td> <td><input type="submit" value="Edit" name="update"></td> <td><input type="submit" value="Delete" name="delete"></td> </tr> <?php } } ?> </table> </form> <?php global $wpdb; $id= $print->id; $table= 'wp_contact_form'; if (isset($_POST['update'])) { $data =array( 'names' => $_POST['yourname'], 'emails' => $_POST['customer_email'], 'gender' => $_POST['customer_gender'], 'age' => $_POST['customer_age'] ); $wherecondition=array( 'id'=>$id ); $wpdb->update($table, $data, $wherecondition); // $wpdb->update('table_name', array('id'=>'1', 'name'=>'parvez', array('id' => '2'))); } if (isset($_POST['delete'])) { // echo "gg"; // die; $wpdb::delete($table, $wherecondition); } ?>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)