vorige-volgende-paginanummering

Gesponsorde koppelingen

PHP script bestanden

  1. vorige-volgende-paginanummering

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?

    //-- get number total replies
    $sql = "SELECT COUNT(id) FROM $table_replies WHERE tid = '" . $_GET['id'] . "' ORDER BY id";
    $res = mysql_query($sql);
    $total_replies = mysql_result($res, 0);
    
    //-- get replies
    if (!$_GET['replies'])
    {

        $replies = "0";
        $sql = "SELECT id,fid,naam,email,msg,datum,datum_edit FROM $table_replies WHERE tid = '" . $_GET['id'] . "' ORDER BY id LIMIT 0,10";
    }

    else
        $sql = "SELECT id,fid,naam,email,msg,datum,datum_edit FROM $table_replies WHERE tid = '" . $_GET['id'] . "' ORDER BY id LIMIT " . $_GET['replies'] . ",10";
    
    $res = mysql_query($sql);

                //-- loop through reactions
                if (mysql_num_rows($res) >= 1)
                {

                      while ($row = mysql_fetch_array($res))
                      {

                          echo "toon de reacties of whatever";
                       }
    }

                else
                {
                     echo "niets gevonden";
                }


    //-- unset + set some vars
    unset($p);
    $u = 0;
    $a = 1;
    $p = 0;
    //-- loop through total reactions
    for ($i = 0; $i <= $total_replies && $total_replies > 10; $i++)
    {

        //-- check if $u is smaller then 10 and if
        //-- the page hasn't been set earlier

        if ($u < 10 && $a != $p)
        {

            $num = $p + 1;
            
            if (!$num_replies && $num_replies != "0")
                $num_replies = "0";
            else
                $num_replies = $num_replies + 10;
            
            //-- check if current page is the page which's about to get generated
            if ($num_replies == $_GET['replies'] || $num_replies == $replies)
                $pages[$p] = "<b>" . $num . "</b>";
            else
                $pages[$p] = "<a href=\"" . $_SERVER['PHP_SELF'] . "?id=" . $_GET['id'] . "&cat=" . $_GET['cat'] . "&replies=" . $num_replies . "\">" . $num . "</a>";
            $a = $p;

        }

        //-- when $u is bigger then 10
        //-- start the loop of ten posts again

        elseif ($u >= 10)
        {

            unset($u);
            $p++;
        }

        
        //-- count $u
        $u++;
    }



                //-- show navigation to skip pages
    for ($i = 0; $i < count($pages); $i++)
    {

        if ($i == 0)
            echo $pages[$i];
        else
            echo " | " . $pages[$i];
    }

?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.