Web Design Forum: pagination problems - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

pagination problems Rate Topic: -----

#1 User is offline   abeer 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 478
  • Joined: 18-January 09
  • Reputation: 4
  • Gender:Male
  • Location:Dhaka
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 24 January 2012 - 08:49 AM

Hi there
Please visit the site 1st

site is here

look at the index page content below the sentence "below content will come from database"

a pragraph there and below the paragraph there is

pages 1,2

if i click page 2 the page appera with the text " paragraph 2 for index page (page2)is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been ....bla bla bla..."

thats mean pagination happens sucessfully and the index page url is

?id=1

But in the button apple i also insertes two pages page 1 is showing but after clicking the page 2... it goes to the index page's 2

here is my full code

<?php mysql_connect('mysql2', 'pegu', 'segu') or die('Connection Failed');
mysql_select_db('legu') or die('Database not found');
$iDefaultRecord = 1; 
$id = isset($_GET['id']) ? filter_var($_GET['id'], FILTER_VALIDATE_INT) : $iDefaultRecord;
  $result = mysql_query("SELECT title, dtl, meta_d, meta_k FROM page WHERE id=$id");
  if (!mysql_num_rows($result)) {     header('Location: 404.php', true, 404);     die();}$row = mysql_fetch_array($result);$title = stripslashes($row['title']);$dtl = stripslashes($row['dtl']);$meta_d = stripslashes($row['meta_d']);$meta_k = stripslashes($row['meta_k']);

$pages = explode("{newpage}", $dtl); 
 
if(isset($_GET['page']) && $_GET['page'] > 0) 
{ 
    $current_page = $_GET['page']; 
    if($current_page > count($pages)) 
    { 
        $current_page = count($pages); 
    } 
} 
else 
{ 
    $current_page = 1; 
} 
 
$description = $pages[$current_page - 1]; 
  
$navigation = "Pages: "; 
for ($i = 1; $i <= count($pages); $i++)  
{ 
    if($i == $current_page) 
    { 
        $navigation .= "<b>"; 
    } 
    $navigation .= "<a href='?page=" . $i . "'> " . $i . "</a> "; 
    if($i == $current_page) 
    { 
        $navigation .= "</b>"; 
    } 
} 
 
?> 
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="<?php echo $meta_k; ?>" />
<meta name="description" content="<?php echo $meta_d; ?>" />

<title><?php echo $title; ?></title>
<link rel="stylesheet" href="cssReset.css" />
<link rel="stylesheet" href="style.css" />
<style type="text/css"> 
img, div, a, li, span{behavior:url(iepngfix.htc);}
</style> 

</head>

<body>

<div id="top">


	<div id="banner">
    
    <h1><a href="#">Environmental.com</a> <span>site slogan here</span></h1>
    
   </div>
    
    <p id="help">Help Line 24 /7 Support  1800 3246 345</p>
    
   
    
    <div id="nav">
    
    	<ul>
        
        	<li><a href="?id=1" class="pageitem">index</a></li>
            <li><a href="?id=2" class="pageitem">apple</a></li>
            <li><a href="?id=3" class="pageitem">banana</a></li>
            <li><a href="?id=4" class="pageitem active">orange</a></li>
            <li><a href="?id=5" class="pageitem">lemon</a></li>
            <li><a href="?id=6" class="pageitem">nut</a></li>
        
        </ul>
    <div style="clear:both"></div>
    </div><!--end of navigation-->
    
    <div id="glow">
        
    
    </div>

    
    
	
<div style="clear:both"></div>
</div><!-- end of top-->

<div style="clear:both"></div>

<div id="content">


		<div id="left">
				
                
                <div id="box1">
                
                	<img src="Images/hand.png" alt="Hand" />
                    <h3>below content will come from database</h3>
                    <?php echo $description; ?>
                    <p><?php echo $navigation;?></p>
                
                </div><!-- end of box1-->

				<div style="clear:both"></div>


               <!-- end of box2-->
				<div style="clear:both"></div>

                <!-- end of box3-->
                
				<div style="clear:both"></div>
                <div id="read">
                
               
                
                </div>
                
                
                
         </div><!-- end of left div-->
         
         
         <div id="right">
         
         
         	
                
                
            
            
            
            </div>
         
         
         </div><!-- end of right div-->

<div style="clear:both"></div>

</div><!-- end of content-->

<div style="clear:both"></div>

<div id="footer">


        
               

</div><!-- end of footer-->




</body>
</html>

0

#2 User is offline   abeer 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 478
  • Joined: 18-January 09
  • Reputation: 4
  • Gender:Male
  • Location:Dhaka
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 24 January 2012 - 12:02 PM

look at the url..

when i am in index page where ?id=1. the url is

http://www.rintlbd.com/?id=1

and when i am clicking the pagination pages 1 or 2 then url becomes

http://www.rintlbd.com/?page=1
http://www.rintlbd.com/?page=2

so sucesfully pagination happens in this index page

But when i am in button "apple"
where ?id=2

url is http://www.rintlbd.com/?id=2

and when i am clicking the pagination pages 1 or 2

url becomes

http://www.rintlbd.com/?page=1
http://www.rintlbd.com/?page=2

same as index page so the index page content appears

and thats my problem

please help me out
0

#3 User is offline   GalaxyTramp 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 120
  • Joined: 09-December 11
  • Reputation: 16
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 24 January 2012 - 12:03 PM

Hi

You need to add an id to your pagination. Try this:

 <?php mysql_connect('mysql2', 'pegu', 'segu') or die('Connection Failed');
mysql_select_db('legu') or die('Database not found');
$iDefaultRecord = 1; 
$id = isset($_GET['id']) ? filter_var($_GET['id'], FILTER_VALIDATE_INT) : $iDefaultRecord;
  $result = mysql_query("SELECT title, dtl, meta_d, meta_k FROM page WHERE id=$id");
  if (!mysql_num_rows($result)) {     header('Location: 404.php', true, 404);     die();}$row = mysql_fetch_array($result);$title = stripslashes($row['title']);$dtl = stripslashes($row['dtl']);$meta_d = stripslashes($row['meta_d']);$meta_k = stripslashes($row['meta_k']);

$pages = explode("{newpage}", $dtl); 
 
if(isset($_GET['page']) && $_GET['page'] > 0) 
{ 
    $current_page = $_GET['page']; 
    if($current_page > count($pages)) 
    { 
        $current_page = count($pages); 
    } 
} 
else 
{ 
    $current_page = 1; 
} 
 
$description = $pages[$current_page - 1]; 
  
$navigation = "Pages: "; 
for ($i = 1; $i <= count($pages); $i++)  
{ 
    if($i == $current_page) 
    { 
        $navigation .= "<b>"; 
    } 
    $navigation .= "<a href='?page=" . $i . "&id=" . $id . "'> " . $i . "</a> "; 
    if($i == $current_page) 
    { 
        $navigation .= "</b>"; 
    } 
} 
 
?>

1

#4 User is offline   abeer 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 478
  • Joined: 18-January 09
  • Reputation: 4
  • Gender:Male
  • Location:Dhaka
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 24 January 2012 - 12:14 PM

:) sucessfully done thanks mate for the help.... +1 for you :D
0

#5 User is offline   GalaxyTramp 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 120
  • Joined: 09-December 11
  • Reputation: 16
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 24 January 2012 - 12:15 PM

View Postabeer, on 24 January 2012 - 12:14 PM, said:

:) sucessfully done thanks mate for the help.... +1 for you :D


No probs :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users