PHP分页多个表? 9lessons.info主题

时间:2013-05-22 08:41:21

标签: php mysql pagination multiple-tables

我有6张桌子。如何加入paginagion? 请帮忙? TNX

我找到了一个使用PHP和MySQL的分页条目示例,我从这里下载了它。我发现它只是为一张桌子设计的。

现在我的问题是如何分页“多个查询表”(临时组合的2个或多个表)。我的想法是从它创建一个派生表,但它仍然失败。

也许我做错了,所以有人可以帮我找出答案。什么应该是我正确的查询?

表格

entry (entry, ent_seq)
k_ele (entry, keb)
r_ele (entry, reb)
sense (SID, entry)
s_gloss_eng (GID_eng, SID, main)
s_gloss_mn (GID_mn, SID, main_mn)

我的代码是

<?php
$query_pag_data = 
"SELECT e.ent_seq,
GROUP_CONCAT(DISTINCT kei.keb SEPARATOR'; ')AS kebs, 
    GROUP_CONCAT(DISTINCT rei.reb SEPARATOR '; ') AS rebs,
GROUP_CONCAT(DISTINCT sei.mean SEPARATOR '; ') AS means,
GROUP_CONCAT(DISTINCT sem.mean_mn SEPARATOR '; ') AS meanmn,            
sem.up_date
FROM s_gloss_mn sem
LEFT JOIN s_gloss_eng sei ON sem.SID = sei.SID
LEFT JOIN sense se ON se.SID = sem.SID
LEFT JOIN k_ele kei ON kei.entry = se.entry
LEFT JOIN r_ele rei ON rei.entry = kei.entry
LEFT JOIN entry e ON e.entry = rei.entry
WHERE sem.up_date 
GROUP BY e.entry
ORDER BY sem.up_date DESC";

$result_pag_data = mysql_query($query_pag_data) or die('MySql Error' . mysql_error());
$finaldata = "";
$tablehead="<tr>
<td width='8%'>ID</td>
<td width='20%'>Word</td>
<td width='20%'>Hiragana</td>
<td width='22%'>English</td>
<td width='25%'>Mongolia</td>
<td width='5%'>Edit</td>
</tr>";

while($row = mysql_fetch_array($result_pag_data)) {
    $id=$row['ent_seq'];
    $kanji=$row['kebs'];
    $readings=$row['rebs'];
    $mean_eng=$row['means'];
    $mean_mn=$row['meanmn'];

$tabledata.="<tr id='$id' class='edit_tr_wc'>

<td class='edit_td_wc' >
    <span id='five_$id' class='text_wc'>$id</span>
    <input type='text' value='$id' class='editbox_wc' id='five_input_$id' />
</td>

<td class='edit_td_wc' >
    <span id='one_$id' class='text_wc'>$kanji</span>
    <input type='text' value='$kanji' class='editbox_wc' id='one_input_$id' />
</td>

<td class='edit_td_wc' >
    <span id='two_$id' class='text_wc'>$readings</span> 
    <input type='text' value='$readings' class='editbox_wc' id='two_input_$id'/>
</td>

<td class='edit_td_wc' >
    <span id='three_$id' class='text_wc'>$mean_eng</span> 
    <input type='text' value='$mean_eng' class='editbox_wc' id='three_input_$id'/>
</td>

<td class='edit_td_wc' >
    <span id='four_$id' class='text_wc'>$mean_mn</span> 
    <input type='text' value='$mean_mn' class='editbox_wc' id='four_input_$id'/>
</td>

<td><a href='#' class='Add' id='$id'> ADD </a>
</tr>";}

$finaldata = "<table width='100%' class='edit_wc'>". $tablehead . $tabledata ."</table>"; //     Content for Data

/* Total Count */
$query_pag_num = "SELECT COUNT(*) AS count FROM s_gloss_mn";
$result_pag_num = mysql_query($query_pag_num);
$row = mysql_fetch_array($result_pag_num);
$count = $row['count'];
$no_of_paginations = ceil($count / $per_page);
?>

0 个答案:

没有答案