I hawe some problem with writing a plugin for WP. I need to show some info in content from my db. I write a code that show query from my db dut i hawe problem with pagination, i reed many posts for it (like this:Paginate WordPress $wpdb) but i just don’t understand what i need to do with my code for pagination it. Here is part of my code that show some data from my db:
$sSql = "SELECT * FROM pam INNER JOIN images ON pam.id_fake=images.id_zapis
WHERE id_type = $type LIMIT ... OFFSET ...";
$myData = array();
$myData = $wpdb->get_results($sSql, ARRAY_A);
$count = $wpdb->num_rows;
echo '<div class="tableCont"> <table>';
for ($i = 0; $i<$count; $i++) {
echo '<tr>
<td>';
if($myData[$i+1]['id_fake']==$myData[$i]['id_fake']){
echo '<a class="gallery" rel="group" title="'.$myData[$i]['description'].'" href="'.get_option('siteurl').'/wp-content/uploads/'.$myData[$i]['image'].'">
<img src="'.get_option('siteurl').'/wp-content/uploads/'.imgsmall($myData[$i]['image']).'" class="images" alt=""></a>';
while($myData[$i+1]['id_fake']==$myData[$i]['id_fake']){
echo '<a class="gallery" rel="group" title="'.$myData[$i]['description'].'" href="'.get_option('siteurl').'/wp-content/uploads/'.$myData[$i]['image'].'">
<img src="'.get_option('siteurl').'/wp-content/uploads/'.imgsmall($myData[$i]['image']).'" class="images" alt=""></a>';
$i++;
}
}
else{
echo '<a class="gallery" title="'.$myData[$i]['description'].'" href="'.get_option('siteurl').'/wp-content/uploads/'.$myData[$i]['image'].'">
<img src="'.get_option('siteurl').'/wp-content/uploads/'.imgsmall($myData[$i]['image']).'" class="images" alt="" ></a>';
}
echo '</td>
<td class="description">'.$myData[$i]['description'].'</td>
<td class="price">Price:<br><br>'.$myData[$i]['price'].'</td>
</tr>';
}
echo '</table></div>';
can you help me to paged this code?
The starting point of the process is the query, the preferred solution is the use of a constant with it (pay attention to the use of $wpdb->prepare to sanitize the query parameters):