hi guys. I am completely new to wordpress, and stuck in a problem. please if you know the solution, then share with me.
I have created a custom table in wp database. and I am inserting the data in that table from front end and the data is successfuly inserted in table.
Now I want to retrieve the data at admin side. I have created a plugin type file for it. and showing the results. but when I give my custom table name in the "select" query, then the admin side of wp stop working and simple doesn't display anything, but when I do the same settings for any wp built in table, then it works fine.
here is my code. and please if anyone knows the solution then share.
thanks in advance.
<?php
add_action('admin_menu', 'reservation_admin_actions');
function reservation_admin_actions(){
add_options_page('Hotel Reservation', 'Hotel Reservation', 'manage_options', __FILE__, 'reservation_admin');
}
function reservation_admin(){
?>
<div class="wrap">
<h2>Hotel Reservations List</h2>
</div>
<table border="1" class="widefat">
<thead>
<tr>
<th>Date From</th>
<th>Date To</th>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Outlet</th>
<th>Subject</th>
<th>Message</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
// $qry = mysql_query("SELECT * FROM wp_reservation ORDER By id DESC");
// while($result = mysql_fetch_assoc($qry))
// {
global $wpdb;
$result = $wpdb->get_results ("SELECT * FROM wp_reservation where name != '' ORDER BY id DESC");
foreach ( $result as $data ) {
?>
<tr>
<td><?php echo $data->date_from; ?></td>
<td><?php echo $data->date_to; ?></td>
<td><?php echo $data->name; ?></td>
<td><?php echo $data->email; ?></td>
<td><?php echo $data->phone; ?></td>
<td><?php echo $data->outlet; ?></td>
<td><?php echo $data->subject; ?></td>
<td><?php echo $data->message; ?></td>
<td>id; ?>">Delete</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php
}
if(isset($_GET['id'])) {
mysql_query("DELETE FROM wp_reservation WHERE id = '".$_GET['id']."'");
//header("location: index.php");
exit();
}
?>
↧
khan143 on "How to display the custom table data on admin panel of wordpress"
↧