I have created a plugin for data insert from WP dashboard. Data has inserted & updated successfully, I want to add a pagination on my list(view)page. I am new developer. this my list-page code.
<?php
function wp_schools_list() {
?>
<link type="text/css" href="<?php echo WP_PLUGIN_URL; ?>mywp/sinetiks-schools/style-admin.css" rel="stylesheet" />
<div class="wrap abs">
<h2>Schools</h2>
<div class="tablenav top">
<div class="alignleft actions">
<a href="<?php echo admin_url('admin.php?page=mywp_schools_create'); ?>">Add New</a>
</div>
<br class="clear">
</div>
<?php
$path_array = wp_upload_dir()['baseurl']; // wp_upload_dir has diffrent types of array I am used 'baseurl' for path
global $wpdb;
$table_name = $wpdb->prefix . "school";
$rows = $wpdb->get_results("SELECT id,code,name,image_name from $table_name");
?>
<table class='wp-list-table widefat fixed striped posts'>
<tr>
<th class="manage-column ss-list-width">ID</th>
<th class="manage-column ss-list-width">Code</th>
<th class="manage-column ss-list-width">Name</th>
<th class="manage-column ss-list-width">Image</th>
<th> </th>
<th> </th>
</tr>
<?php foreach ($rows as $row) { ?>
<tr>
<td class="manage-column ss-list-width"><?php echo $row->id; ?></td>
<td class="manage-column ss-list-width"><?php echo $row->code; ?></td>
<td class="manage-column ss-list-width"><?php echo $row->name; ?></td>
<td><img src="<?php echo $path_array; ?>/2016/12/<?php echo $row->image_name;?> " width="100" height="100" /> </td>
<td><a href="<?php echo admin_url('admin.php?page=wp_schools_update&id=' . $row->id); ?>">Update</a></td>
<td><a href="<?php echo admin_url('admin.php?page=wp_schools_delete&id=' . $row->id); ?>">Delete</a></td>
</tr>
<?php } ?>
</table>
</div>
<?php
}
Try this code.
Updated