Pagenation Help

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Pagenation Help

    hi friends i try to add a next and previous here real coding


    Code:
    class NewsScript
    {
        var $maxLength,
            $lim,            /* Num items to show */
            $template,        /* Template to use */
            $db_name,        /* DB Settings */
            $db_host,
            $db_user,
            $db_password,
            $connection;
        
        /**
         * Constructor, executed when we make a new object.
         *
         * @return NewsScript Object
         */
        function NewsScript()
        {
            // Import Database settings etc.
            require('config.php');
            
            $this->db_host = $db_host;
            $this->db_name = $db_name;
            $this->db_user = $db_user;
            $this->db_password = $db_password;
            $this->lim = $lim;
            $this->template = $template;
        }
        
        /**
         *    Display ALL news articles
         *
         */
        function displayAll()
        {
            $this->connect();
            
            // Use the limit in our settings to decide how many to show
            $result = mysql_query("SELECT * FROM news ORDER BY date DESC LIMIT 0, $this->lim");
            
            /* While we have more rows display them */
            while($row = mysql_fetch_assoc($result))
            {
                // Display the row
                $id = $row['id'];
                $author =  $row['author'];
                $content = $row['content'];
                $date = $this->convertDate($row['date']);
                
                /*
                Variables are used in the template file to display news info
                */
                require($this->template);
                
            }
            
            $this->close();
        }
        
        /**
         * Display a single news item given it's ID.
         *
         * @param $id - ID of item to display
         * @return true/false
         */
        function displayItem($id)
        {
            if(is_numeric($id))
            {
                $this->connect();
                
                $result = mysql_query("SELECT * FROM newstbl WHERE id = '$id'");
                $row = mysql_fetch_assoc($result);
                
                $author =  $row['author'];
                $content = $row['content'];
                $date = $this->convertDate($row['date']);
                
                require($this->template); // Show item with our template.
                
                $this->close();
                return true;
            }
            else return false; // Not valid number
            
        }
    here i try my coding

    Code:
    class NewsScript
    {
        var $maxLength,
            $lim,            /* Num items to show */
            $template,        /* Template to use */
            $db_name,        /* DB Settings */
            $db_host,
            $db_user,
            $db_password,
            $connection;
        
        /**
         * Constructor, executed when we make a new object.
         *
         * @return NewsScript Object
         */
        function NewsScript()
        {
            // Import Database settings etc.
            require('config.php');
            
            $this->db_host = $db_host;
            $this->db_name = $db_name;
            $this->db_user = $db_user;
            $this->db_password = $db_password;
            $this->lim = $lim;
            $this->template = $template;
        }
        
        /**
         *    Display ALL news articles
         *
         */
        function displayAll()
        {
            $this->connect();
    
            
    if ($_GET['page']==NULL){
    $start = 0;
    } else {
    $start = $_GET['page'];
    }
    
    // the if above, states that if the variable in the URL named page has a value, $start will be set to it, otherwise by default it is set to 0, meaning that it will start at the beginning of the table by default.
    
    if($_GET[&#39;page&#39;] < 0){
    header("Location: http://site.com/news.php?page=0&lim=".$lim);
    }
    
            // Use the limit in our settings to decide how many to show
            $result = mysql_query("SELECT * FROM news ORDER BY date DESC LIMIT 0, $this->lim");
            
            /* While we have more rows display them */
            while($row = mysql_fetch_assoc($result))
            {
                // Display the row
                $id = $row[&#39;id&#39;];
                $author =  $row[&#39;author&#39;];
                $content = $row[&#39;content&#39;];
                $date = $this->convertDate($row[&#39;date&#39;]);
    
    
                
                /*
                Variables are used in the template file to display news info
                */
                require($this->template);
    
    
                
            }
            
    
    $previous = $start + $lim;
    $next = $start - $lim;
    echo "<div align=&#39;center&#39;>
         <a href=&#39;http://site.com/news.php?start=".$previous."&#39;>Previous Page</a> - 
         <a href=&#39;http://site.com/news.php?start=".$next."&#39;>Next Page</a>
             </div>
    ";
    
            $this->close();
    
    
        }
    but no result not work help me add please, in the config file lim is add 10 so 10 messages showing in 1 page nomatter how much i dd only 10 show i want to show all help
    Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

    <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>


    #2
    Some days ago you pasted javascript and now class object. thats damn funny. :D

    Comment


      #3
      You are poor in class...try class less script, ...............there are too many errors ...1 i can say
      Code:
      header("Location: http://site.com/news.php?page=0&lim=".$this->lim);

      Comment


        #4
        thats becoz i learn @rukiya i try atleast
        Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

        <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

        Comment


          #5
          atleast help me when i try something why making me fun?
          Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

          <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

          Comment


            #6
            anyway problem solved i make myslf that pagination without help from anybody. i say one thing rukiya bro do not be angry u have help me many time and im greatful but u make fun of others that is very bad never have ego coz that destory
            Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

            <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

            Comment


              #7
              staff close topic
              Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

              <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

              Comment

              Working...
              X