NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Pagination Problems....

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 02-24-2006, 09:21 AM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Feb 2006
Location: Chicago IL
Posts: 73
AllValley is an unknown quantity at this point
 



Pagination Problems....


Hi there! making a portfolio page for my website, and the code seems to work. but the links for pagination do not show up

Here are the files I'm working with
Contents of the callid_port.php file
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Portfolio</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
	include('config.php');
// request text from all the jokes

	include('pagination.php');

	
			echo("<table class='prod' cellpadding='3' border='3'>");
			echo("<tr><td colspan='4'><h3 align='center'>Sort Portfolio By: <a href='id.html'>All</a> | <a href='dsnrs.html'>Designer</a> | <a href='live.html'>Live Sites</a></h3></td></tr>
				<tr>
						<td><h4 align='center'> Design Thumbnail </h4></td><td><h4 align='center'> Design Title </h4></td><td><h4 align='center'> Design Author </h4></td>
						<td><h4 align='center'> Design URL </h4></td>
				</tr>
						");
			
			
	while ( $row = mysql_fetch_array($result) ) {
		$id = $row["ID"];
		$dsnr = $row["dsnr"];
		$img = $row["img"];
		$live = $row["live"];
		$port_desc = $row["port_desc"];
		$href = $row["href"];
		$title = $row["title"];
		
		if (empty($row)) {
		echo("<h1>Coming Soon!</h1>"); }
		elseif($live==1){		
			$ahref = "<a href='" . $href . "' target='_blank'>" . $title . "</a> *Live Site!*" ;
			}else ( $ahref= "Not Live" );
			
		
		echo("<tr><td class='td2'>" . "<a href='/images/" . $img . "' target='_blank'><img width='90px' height='120px' src='/images/" . $img . "' title='Click For Larget Image' border='0' /></a>" . "</td><td class='td3'><p align='center'>"  . $title . "</p>"  .  "</td><td class='td4'>"  . $dsnr . "</td><td class='td5'>" . $ahref .  "</td></tr><tr><td colspan='4'><blockquote> <p align='left'>Design Description:</p>" . $port_desc . "</blockquote></td></tr>");
	}
	 include('pagination2.php');
	echo("</table>");
	;
	?>
</body>
</html>

????: NamePros.com http://www.namepros.com/programming/170787-pagination-problems.html
Contents of pagination.php
Code:
<?

 $limit          = 5;               
    $query_count    = "SELECT count(*) FROM port";    
    $result_count   = mysql_query($query_count);    
    $totalrows      = mysql_num_rows($result_count);

    if(empty($page)){
        $page = 1;
    }
        

    $limitvalue = $page * $limit - ($limit);
    $query  = "SELECT * FROM port LIMIT $limitvalue, $limit";        
    $result = mysql_query($query) or die("Error: " . mysql_error());

    if(mysql_num_rows($result) == 0){
        echo("Nothing to Display!");
    }

    

   
    
	?>
Contents of pagination2.php
Code:
<?

if($page != 1){
        $pageprev = $page--;
        
        echo("<a href=\"callid_port.php&page=$pageprev\">PREV".$limit."</a> ");
    }else{
        echo("PREV".$limit." ");
    }

    $numofpages = $totalrows / $limit;
    
    for($i = 1; $i <= $numofpages; $i++){
        if($i == $page){
            echo($i." ");
        }else{
            echo("<a href=\"callid_port.php?page=$i\">$i</a> ");
        }
    }


    if(($totalrows % $limit) != 0){
        if($i == $page){
            echo($i." ");
        }else{
            echo("<a href=\"callid_port.php?page=$i\">$i</a> ");
        }
    }

    if(($totalrows - ($limit * $page)) > 0){
        $pagenext = $page++;
         
        echo("<a href=\"callid_port.php?page=$pagenext\">NEXT".$limit."</a>");
    }else{
        echo("NEXT".$limit);
    }
    
    mysql_free_result($result); 
	
	?>
It works, but the PREV and NEXT don't show up as links :s
????: NamePros.com http://www.namepros.com/showthread.php?t=170787

Any Ideas? (Link To Page

TIA
__________________
Hassle Free Computing and Web Solutions for Personal and Business!
Rochelle Network Communications!
Last edited by AllValley; 02-24-2006 at 09:34 AM.
AllValley is offline  
Old 02-24-2006, 02:36 PM   #2 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
For pagination, try:
PHP Code:
<?php

$page 
intval($_GET['page']);

$limit 5;
$query_count    "SELECT count(*) FROM port";
$result_count   mysql_query($query_count);
$totalrows      mysql_num_rows($result_count);

if(empty(
$page))
{
  
$page 1;
}

$limitvalue $page $limit - ($limit);
$query  "SELECT * FROM port LIMIT $limitvalue$limit";
$result mysql_query($query) or die("Error: " mysql_error());

if(
mysql_num_rows($result) == 0)
{
  echo(
"Nothing to Display!");
}
?>
And for pagination2
PHP Code:
<?php

if($page != 1)
{
  
$pageprev $page--;
  echo 
'<a href="callid_port.php&page='.$pageprev.'">PREV '.$limit.'</a> ';
????: NamePros.com http://www.namepros.com/showthread.php?t=170787
}
else
{
  echo 
'PREV '.$limit.' ');
}

$numofpages $totalrows $limit;

for(
$i 1$i <= $numofpages$i++)
{
  if(
$i == $page)
  {
    echo 
$i.' ';
  }
  else
  {
    echo 
'<a href="callid_port.php?page='.$i.'">'.$i.'</a> ';
  }
}

if((
$totalrows $limit) != 0)
????: NamePros.com http://www.namepros.com/showthread.php?t=170787
{
  if(
$i == $page)
  {
    echo 
$i.' ';
  }
  else
  {
    echo 
'<a href="callid_port.php?page='.$i.'">'.$i.'</a> ';
  }
}

if((
$totalrows - ($limit $page)) > 0)
{
  
$pagenext $page++;
  echo 
'<a href="callid_port.php?page='.$pagenext.'">NEXT '.$limit.'</a> ';
}
else
{
  echo 
'NEXT '.$limit);
}

@
mysql_free_result($result);

?>
Will take a closer look in a bit... Hope this helps tho


-Eric
Eric is offline  
Old 02-24-2006, 09:35 PM THREAD STARTER               #3 (permalink)
NamePros Member
Join Date: Feb 2006
Location: Chicago IL
Posts: 73
AllValley is an unknown quantity at this point
 



The links still aren't working :S
__________________
Hassle Free Computing and Web Solutions for Personal and Business!
Rochelle Network Communications!
AllValley is offline  
Old 02-24-2006, 10:04 PM   #4 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Ok, try this. And this is all one file btw
????: NamePros.com http://www.namepros.com/showthread.php?t=170787

PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Portfolio</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php

include('config.php');

$page intval($_GET['p']);

if(!
$page || $page == "")
{
  
$page 1;
}

$prev $page 1;
$next $page 1;
$ppage 5;
$limit = ($page $ppage) - $ppage;

$query mysql_query("SELECT ID FROM port") or die("Error: ".mysql_error());
$num mysql_num_rows($query);
$num_pages ceil($num $ppage);

$link '';

if(
$page 1)
{
  
$link .= ' <a href="?p=1">First</a> <a href="?p='.$prev.'">Prev</a> ';
}

for(
$i 1$i <= $num_pages$i++)
{
  if(
$page == $i)
  {
    
$link .= ' <b>['.$i.']</b> ';
  }
  else
  {
    
$link .= ' <a href="?p='.$i.'">'.$i.'</a> ';
  }
}

if(
$page $num_pages)
{
  
$link .= ' <a href="?p='.$next.'">Next</a> <a href="?p='.$num_pages.'">Last</a>';
}

?>
<table class='prod' cellpadding='3' border='3'>
<tr>
  <td colspan='4'><h3 align='center'>Sort Portfolio By: <a href='id.html'>All</a> | <a href='dsnrs.html'>Designer</a> | <a href='live.html'>Live Sites</a></h3></td>
</tr>
<tr>
  <td><h4 align='center'> Design Thumbnail </h4></td><td><h4 align='center'> Design Title </h4></td><td><h4 align='center'> Design Author </h4></td>
  <td><h4 align='center'> Design URL </h4></td>
</tr>
<?php

$query 
mysql_query("SELECT * FROM port LIMIT ".$limit.", ".$ppage) or die("Error: ".mysql_error());

while(
$row mysql_fetch_array($query))
{
  
$id $row["ID"];
  
$dsnr $row["dsnr"];
  
$img $row["img"];
  
$live $row["live"];
  
$port_desc $row["port_desc"];
  
$href $row["href"];
  
$title $row["title"];

  if(empty(
$row))
  {
    echo(
"<h1>Coming Soon!</h1>");
  }
  elseif(
$live==1)
  {
    
$ahref "<a href='" $href "' target='_blank'>" $title "</a> *Live Site!*" ;
  }
  else
  {
    
$ahref "Not Live";
  }
?>
<tr>
  <td class='td2'><a href='/images/<?php echo $img?>' target='_blank'><img width='90px' height='120px' src='/images/<?php echo $img?>' title='Click For Larget Image' border='0' /></a></td>
????: NamePros.com http://www.namepros.com/showthread.php?t=170787
  <td class='td3'><p align='center'><?php echo $title?></p></td>
  <td class='td4'><?php echo $dsnr?></td>
  <td class='td5'><?php echo $ahref?></td>
</tr>
<tr>
  <td colspan='4'><blockquote> <p align='left'>Design Description:</p><? php echo $port_desc?></blockquote></td>
</tr>
<?php
}
?>
</table>
<br />
<?php echo $link?>

</body>
</html>
Eric is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems. They can ruin your day if you don't have the right perspective. BobParsons.com Business Development 0 12-17-2005 12:38 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 04:14 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger