开发者

How I can do client side pagination for DIV elements generated from MYSQL query?

开发者 https://www.devze.com 2023-01-03 23:47 出处:网络
I have this PHP code : $query = \"SELECT * FROM news WHERE news_active = 1 AND news_type = 1 ORDER BY id DESC\";

I have this PHP code :

    $query = "SELECT * FROM news WHERE news_active = 1 AND news_type = 1 ORDER BY id DESC";

     $q2 = "SELECT * FROM st_photos WHERE id = 4 LIMIT 1";
     $r2 = mysql_query($q2);
     $row22 = mysql_fetch_array($r2);

$news_set = mysql_query($query);
$news_set2 = mysql_query($query);
if (mysql_num_rows($news_set) != 0) {

    $r = mysql_fetch_array($news_set);

                                开发者_开发知识库echo "<div id=\"d_coll\">
    <div id=\"top_text\">$row22[img]</div>
               <div id=\"d_image\"><img id=\"larg_p2\" src=\"photos/$r[news_image]\" width=\"320\" height=\"250\" border=\"0\"></div>
               <div style=\"width:300px\"><div id=\"n_text2\">$r[news_part_en]</div>
    </div>
     </div>";
                                }

    if (mysql_num_rows($news_set2) != 0) {

    while ($news = mysql_fetch_array($news_set2)) {

                  echo "<div id=\"n_col\">
                                <div id=\"n_tittle\"><a href=\"view_news_en.php?id=$news[id]\">$news[news_tittle_en]</a>&nbsp;&nbsp;<img src=\"images/bu3.png\" border=\"0\" align=\"middle\"></div>
                                <div id=\"im\"><img onMouseOver=\"MM_swapImage('larg_p2','','photos/$news[news_image]','imgs[$news[id]]','','photos/$news[news_image]',1);up2('$news[news_part_en]')\" onMouseOut=\"MM_swapImgRestore()\" name=\"imgs[$news[id]]\" id=\"imgs[$news[id]]\" src=\"photos/$news[news_image]\" width=\"50\" height=\"50\"></div>
                                <div dir=\"ltr\" id=\"n_div\">$news[news_part_en]&nbsp;&nbsp;&nbsp;<div class=\"mo\"><a href=\"view_news_en.php?id=$news[id]\">MORE</a></div></div>
                              </div>";

                                    }

                                    echo "<div align=\"right\" class=\"arr\"><img src=\"images/prev.png\">&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"images/next.png\"></div>";

                                }

There are 2 images at the end of the code (prev & next), I want to use them to do pagination but I don't want to view any numbers, only these 2 images.

How I can do that?

I think we can do that by using JQuery library, but I don't know how to use it.

Thanks in advance.


you can use one of many plugins, for example here .

you must just remoove thе numbers. you can, i believe;)

or you can write the script by yourself. i'll give you only an idea. let's assume you have 30 rows( from DB).put them into <div> tags, and increase the id of div. the display proparty of first <div> you must set to '', and all others to none. and then, onclick on your buttons, you just change display proparty of div elements...

0

精彩评论

暂无评论...
验证码 换一张
取 消