Jump to content


Photo

Stuck on pagation


  • Please log in to reply
3 replies to this topic

#1 The_Anomaly

The_Anomaly
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 20 July 2006 - 03:54 AM

i have everything pretty much working but its displaying everything not just 5 at a time as i would like it to. I cant seem to find whats wrong. when i click the 1,2,3 links the page in the address bar says it has changed but all fields are still the same. Wanna take a look :)

<?php 

    require_once('Connections/nwodb.php'); 
    @mysql_select_db("nwo") or die("ERROR--CAN'T CONNECT TO DB"); 
     


    $limit          = 5; 	               
    $query_Recordset1    = "SELECT * FROM person ORDER BY LastName ASC";     
    $result_count   = mysql_query($query_Recordset1);     
    $totalrows      = mysql_num_rows($result_count);
   

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

    $limitvalue = $page * $limit - ($limit);  
    //$query_Recordset1  = "SELECT * FROM person ORDER BY LastName ASC";         
    //$result = mysql_query($query) or die("Error: " . mysql_error());  
       
       $Recordset1 = mysql_query($query_Recordset1, $nwodb) or die(mysql_error());
       $row_Recordset1 = mysql_fetch_assoc($Recordset1);
       $totalRows_Recordset1 = mysql_num_rows($Recordset1); 
    if(mysql_num_rows($Recordset1) == 0)
	{ 
        echo("Nothing to Display!"); 
        } 

    $bgcolor = "#E0E0E0"; // light gray 

    echo("<table>"); 
    echo("<tr><td>");
    echo("Member_ID");
    echo("</td><td>");
    echo("Last Name");
    echo("</td><td>");
    echo("First Name");
    echo("</td></tr>");
     
    while($row_Recordset1 = mysql_fetch_array($Recordset1))
    { 
        if ($bgcolor == "#E0E0E0")
	   { 
            	$bgcolor = "#FFFFFF"; 
            }else
	      { 
                 $bgcolor = "#E0E0E0"; 
              } 
  	
    			echo("<tr bgcolor=".$bgcolor."><td width=\"20%\">");
    			echo ($row_Recordset1["Person_ID"]);
    			echo ("</td><td width=\"40%\">");       
    			echo($row_Recordset1["LastName"]);
           	        echo ("</td><td>");        
    			echo($row_Recordset1["FirstName"]); 
    			echo("</td></tr>"); 
    } 

    echo("</table>"); 
//shows the previous # entries link
    if($page != 1){  
        $pageprev = $page--;          
        echo("<a href=\"pagation.php=$pageprev\">PREV".$limit."</a> ");  
    	}else
          { 
        	echo("PREV ".$limit." "); 
    	  } 
//shows the number of pages that can be selected from
    $numofpages = $totalrows / $limit;      
    for($i = 1; $i <= $numofpages; $i++)
      { 
        if($i == $page)
          { 
            echo($i." "); 
           }else
             { 
                echo("<a href=\"pagation.php?page=$i\">$i</a> "); 
             } 
          } 

//shows the next # enties link
    if(($totalrows % $limit) != 0)
       { 
        if($i == $page){ 
            echo($i." "); 
        }else
          { 
            echo("<a href=\"pagation.php?page=$i\">$i</a> "); 
           } 
       } 

    if(($totalrows - ($limit * $page)) > 0){ 
        $pagenext = $page++;          
        echo("<a href=\"pagation.php?page=$pagenext\">NEXT ".$limit."</a>");  
    }else{ 
        echo("NEXT ".$limit);  
    } 
     
    mysql_free_result($Recordset1); 

?> 

I know its sloppy right now :|

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 July 2006 - 04:08 AM

take a look at this and change whats needed ok

good luck



<?

//add database

if(!isset($_GET['page'])){ 
    $page = 1; 
} else { 
    $page = $_GET['page']; 
} 

$max_results = 1; 

$from = (($page * $max_results) - $max_results); 

$query="select * from messages_copied  LIMIT $from, $max_results";


$result=mysql_query($query);
while($record=mysql_fetch_assoc($result)){


echo"<table align='center' width='300'border='4' bordercolor='black'><td align='left'><b>Members Id:<font color='red'><br>".$record["sent_id"]."</font><br> User Name: <font color='red'><br>".$record["members_name"]."</font><br>
Sent Time: <font color='red'><br>".$record["time"]."</font> <br> Sent Date <font color='red'><br>".$record["date"]."</font> </b></td><td align='center' valign='top'><b>Members Message <font color='red'>$page</font><b>
<br><br><b><div align='left'><textarea col='7' rows='7'style='color: white; background-color: #A0C0F0'>".$record["message"]."</textarea></td></b></div><table>";





echo "<table align='center' width='300'border='4' bordercolor='black'><td align='center'><b>";


$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM messages_copied "),0); 


$total_pages = ceil($total_results / $max_results); 


 


if($page > 1){ 
    $prev = ($page - 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"></a>"; 
} 

for($i = 1; $i <= $total_pages; $i++){ 
    if(($page) == $i){ 
        echo "$i "; 
        } else { 
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; 
    } 
} 


if($page < $total_pages){ 
    $next = ($page + 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\"></a>";

} 

 }

?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 The_Anomaly

The_Anomaly
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 20 July 2006 - 12:38 PM

Thats seems to work fine, but when i change it to display more than 1 item the page is a blank white.

#4 The_Anomaly

The_Anomaly
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 20 July 2006 - 07:36 PM

anyone? :(




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users