Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Page Numbering Help!

    Can Someone Add Page Numbering To This Script Please

    Code:
    <link rel=stylesheet href=../style.css type=text/css>
    <?php
    include"mysql_connect.php";
    include"functions.php";
    
    $username=$_SESSION['username'];
    
    $fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));
    $userlevel=$fetch->userlevel;
    
    $topics=mysql_fetch_object(mysql_query("SELECT * FROM topics WHERE id='$username'"));
    
    $date=gmdate('F jS Y');
    $time=gmdate('g:i:s a');
    $datetime="$date at $time";
    
    ?>
    <form id="form" name="form" method="post" action="newtopic.php">
      <input type="submit" name="Submit" value="New Topic!" />
    </form>
    <table width=400 border=1 cellpadding=2 cellspacing=0 bordercolor=black class=table align=center>
      <tr>
        <td width=100% align=center class=header colspan=2>Forum</td>
        </tr>
    
    <?php
    $query = mysql_query("SELECT * FROM `topics` WHERE `type`='important' ORDER BY `lastpost` DESC");
    while($topics=mysql_fetch_object($query)){
    
    if($topics->type == "important"){
    
    if($userlevel == "Admin"){
    echo "<tr><td class=text><u><b>Important:</b></u> "; 
    echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
    if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
    echo"</td>
    <td>
    <a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
    </td>
    </tr>";
    }
    
    if($userlevel == "Head"){
    echo "<tr><td class=text><u><b>Important:</b></u> "; 
    echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
    if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
    echo"</td>
    <td>
    <a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
    </td>
    </tr>";
    }
    
    if($userlevel == "Mod"){
    echo "<tr><td class=text><u><b>Important:</b></u> "; 
    echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
    if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
    echo"</td>
    <td>
    <a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
    </td>
    </tr>";
    }
    
    if($userlevel == "Users"){
    echo "<tr><td class=text><u><b>Important:</b></u> "; 
    echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
    if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
    echo"</td></tr>";
    }
    }
    }
    
    $query = mysql_query("SELECT * FROM `topics` WHERE `type`='sticky' ORDER BY `lastpost` DESC");
    while($topics=mysql_fetch_object($query)){
    
    if($topics->type == "sticky"){
    
    if($userlevel == "Admin"){
    echo "<tr><td class=text><u>Sticky:</u> "; 
    echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
    if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
    echo"</td>
    <td>
    <a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
    </td>
    </tr>";
    }
    
    if($userlevel == "Head"){
    echo "<tr><td class=text><u>Sticky:</u> "; 
    echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
    if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
    echo"</td>
    <td>
    <a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
    </td>
    </tr>";
    }
    
    if($userlevel == "Mod"){
    echo "<tr><td class=text><u>Sticky:</u> "; 
    echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
    if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
    echo"</td>
    <td>
    <a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
    </td>
    </tr>";
    }
    
    if($userlevel == "Users"){
    echo "<tr><td class=text><u>Sticky:</u> "; 
    echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
    if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
    echo"</td></tr>";
    }
    }
    }
    
    $query = mysql_query("SELECT * FROM `topics` WHERE `type`='normal' ORDER BY `lastpost` DESC");
    while($topics=mysql_fetch_object($query)){
    
    if($topics->type == "normal"){
    
    if($userlevel == "Admin"){
    echo "<tr><td class=text><a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
    if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
    echo"</td>
    <td>
    <a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
    </td>
    </tr>";
    }
    
    if($userlevel == "Head"){
    echo "<tr><td class=text><a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
    if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
    echo"</td>
    <td>
    <a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
    </td>
    </tr>";
    }
    
    if($userlevel == "Mod"){
    echo "<tr><td class=text><a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
    if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
    echo"</td>
    <td>
    <a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
    </td>
    </tr>";
    }
    
    if($userlevel == "Users"){
    echo "<tr><td class=text><a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
    if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
    echo"</td></tr>";
    }
    }
    }
    
    $delete=$_GET[delete];
    if($delete) {
    
    if($userlevel == "Admin"){
    echo "<META HTTP-EQUIV=\"Refresh\" target=\"_top\" CONTENT=\"0; URL=forum.php\">";
    echo"Deleted!";
    mysql_query("DELETE FROM topics WHERE id='$delete'");
    mysql_query("DELETE FROM posts WHERE topicid='$delete'");
    mysql_query("INSERT INTO `staff_logs` (`username`, `action`, `date`) VALUES ('$username', 'Delete Forum Topic = $delete', '$datetime');") or die (mysql_error());
    
    }
    
    if($userlevel == "Head"){
    mysql_query("INSERT INTO `staff_logs` (`username`, `action`, `date`) VALUES ('$username', 'Delete Forum Topic = $delete', '$datetime') LIMIT 1;") or die (mysql_error());
    mysql_query("DELETE FROM topics WHERE id='$delete'");
    mysql_query("DELETE FROM posts WHERE topicid='$delete'");
    echo "<META HTTP-EQUIV=\"Refresh\" target=\"_top\" CONTENT=\"0; URL=forum.php\">";
    echo"Deleted!";
    }
    
    if($userlevel == "Mod"){
    mysql_query("INSERT INTO `staff_logs` (`username`, `action`, `date`) VALUES ('$username', 'Delete Forum Topic = $delete', '$datetime');") or die (mysql_error());
    mysql_query("DELETE FROM topics WHERE id='$delete'");
    mysql_query("DELETE FROM posts WHERE topicid='$delete'");
    echo "<META HTTP-EQUIV=\"Refresh\" target=\"_top\" CONTENT=\"0; URL=forum.php\">";
    echo"Deleted!";
    }
    
    if($userlevel == "User"){
    echo"Nice Try!<br>You Actions Have Been Logged!";
    mysql_query("INSERT INTO `user_logs` (`username`, `action`, `date`) VALUES ('$username', 'Delete Forum Topic = $delete', '$datetime');") 
    or die (mysql_error());
    }
    
    }
    
    ?>
    
    </table>
    Thanks,
    birdbrain24

  • #2
    Regular Coder stevenmw's Avatar
    Join Date
    Jun 2007
    Location
    OK
    Posts
    497
    Thanks
    27
    Thanked 31 Times in 31 Posts

    Page Numbering

    This tutorials is very good at explaining page numbering. Try taking a look.

    http://www.phpfreaks.com/tutorials/73/0.php

  • #3
    New Coder
    Join Date
    Jul 2007
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I did it and i gets the page numbering but it goes over the limit on the first page and shows everything and on the second page it's the exact same stuff as the first page!

  • #4
    New Coder
    Join Date
    Jul 2007
    Location
    Latin America
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I have no idea where you want the pages to go BUT here is an example:

    Code:
    $Number_Threads = mysql_num_rows(mysql_query("SELECT * FROM topics WHERE id = '$username'"));
    $Threads_Per_Page = 20;
    $Num_Pages = floor($Number_Threads / $Threads_Per_Page);
    for( $i = 0; $i <= $Num_Pages; $i++){
       echo "<a href=\"forum.php?id=$Forum_ID_Here&page=$i\">";
    }
    Thats a really basic example, you will need to edit the echo part to make the link suit your needs, just base from that.

  • #5
    New Coder
    Join Date
    Jul 2007
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks I Hope This Will Work!

  • #6
    New Coder
    Join Date
    Jul 2007
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Same Problem With This One As The Last One! Could Someone Please Add It For Me!

  • #7
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Don't demand that someone code your script for you. This is a learning forum, not a get-free-work forum. If the previous pagination script didn't work for you, have a look at Firepage's script, which is excellent and easy to implement. Find it at www.firepages.com.au

  • #8
    New Coder
    Join Date
    Jul 2007
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I Am Not Trying To Demand Someone To Do It For Me I Am Asking And I Am Not Trying To Get Free Work Done I Coded ALl What Is Done Myself! Just So You Know! And It Will Try That Link You Gave Me!

  • #9
    New Coder
    Join Date
    Jul 2007
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Still No Luck With That Link! I Don't Get This! I Tried About 15 Tutorails Showing You How To Do It With ! Query But My Script Haas 3 Queries Thats Why I Can't Do It! If Anyone Can Help Can You Please Do So!

    All Thankz,
    Birdbrain24

  • #10
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Here is the class: firepages pagination class Firepages class intentionally steered clear of having his class deal with SQL statements that way it would be more extendable and should work in your case.
    Last edited by StupidRalph; 07-12-2007 at 07:55 PM. Reason: spelling error
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #11
    New Coder
    Join Date
    Jul 2007
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I Will Try The Link!

  • #12
    New Coder
    Join Date
    Jul 2007
    Location
    Latin America
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you sure it's my code wrong and not one of your SQL Queries?

    I suggest adding: or print mysql_error()
    at the end of every Query and before the semi-colon ( ; ).

    And post whatever error you get, if you don't get any you might as well tell us whats the problem you said my code did.

    Oh and, the code I give you requires you to edit the query that fetches the topics and add a LIMIT clause so you limit the amount of topics.
    Last edited by Boshi; 07-12-2007 at 08:46 PM.

  • #13
    New Coder
    Join Date
    Jul 2007
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Boshi View Post
    Are you sure it's my code wrong and not one of your SQL Queries?

    I suggest adding: or print mysql_error()
    at the end of every Query and before the semi-colon ( ; ).

    And post whatever error you get, if you don't get any you might as well tell us whats the problem you said my code did.

    Oh and, the code I give you requires you to edit the query that fetches the topics and add a LIMIT clause so you limit the amount of topics.
    I Know Your Code Will Work For 1 Querie But That Code Wouldn't Work For 3 Queries! I Don't Think So Anyways! If It Do Work I Am Seriously Doing Something Wrong! Can Someone Please Help!

  • #14
    New Coder
    Join Date
    Jul 2007
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Boshi View Post
    Are you sure it's my code wrong and not one of your SQL Queries?

    I suggest adding: or print mysql_error()
    at the end of every Query and before the semi-colon ( ; ).

    And post whatever error you get, if you don't get any you might as well tell us whats the problem you said my code did.

    Oh and, the code I give you requires you to edit the query that fetches the topics and add a LIMIT clause so you limit the amount of topics.
    Thats My Problem! Because There Are 3 Queries And This Scripts Shows The Topics For A Forum That I Am Making For My Site It Has 3 Levels Of Topics! Important, Sticky and Normal! And They All Have Their Own Queries! So How Can I Put A Limit On Them!

  • #15
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Why don't you use one query to retrieve all three types of threads? You could simply use a union to force them sorted the way you want...

    Code:
    SELECT blah, 1 as sort_order
    FROM blah
    WHERE type = 'IMPORTANT'
    UNION ALL
    SELECT blah, 2 as sort_order
    FROM blah
    WHERE type = 'STICKY'
    UNION ALL
    SELECT blah, 3 as sort_order
    FROM blah
    WHERE type = 'NORMAL'
    ORDER BY sort_order, lastpost DESC


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •