【发布时间】:2016-01-08 07:29:36
【问题描述】:
我在为 WP 编写插件时遇到了一些问题。我需要在我的数据库中显示一些内容信息。我编写了一个代码来显示来自我的数据库的查询,因为我遇到了分页问题,我为它写了很多帖子(例如:Paginate Wordpress $wpdb),但我只是不明白我需要对我的代码进行分页做什么。这是我的代码的一部分,它显示了我的数据库中的一些数据:
$sSql = "SELECT * FROM pam INNER JOIN images ON pam.id_fake=images.id_zapisWHERE 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>';
你能帮我分页这段代码吗?
【问题讨论】:
标签: php wordpress pagination