Jump to content

Problem with view next page record in paginated pages


IreneLing

Recommended Posts

Hi all .

I have a script , which will display the records from sql . If user wish to view more details of the record , they can click view .

 

eeee.jpg

 

      echo "<td>$objResult[Message] </td>";
   echo "<td>$objResult[mylocaltime] </td>";
   echo '<td><a href="historydetails.php?id=' . $objResult[Groupnumber] . '">View</a></td>';

 

Then it will link to a page which will display more details according to the Groupnumber .

Which will display 2 records per page .

 

cccc.jpg

 

<?

$groupnumber = $_GET['id'];

$strSQL = "SELECT * FROM esp WHERE Groupnumber='$groupnumber'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);

$Per_Page = 2;   // Per Page

$Page = $_GET["Page"];
if(!$_GET["Page"])
{
	$Page=1;
}

$Prev_Page = $Page-1;
$Next_Page = $Page+1;

$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
	$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
	$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
	$Num_Pages =($Num_Rows/$Per_Page)+1;
	$Num_Pages = (int)$Num_Pages;
}


$strSQL .=" order  by id DESC LIMIT $Page_Start , $Per_Page";
$objQuery  = mysql_query($strSQL);

?>

 

But when I click next to view the third record , then the table will become blank .

 

bbbb.jpg

 

Is it because when I click to next page , the $groupnumber  is no longer getting the data from $_GET['id'] ?

Or is there any other problem?

 

Thanks for every reply .

 

Link to comment
Share on other sites

Is it because when I click to next page , the $groupnumber  is no longer getting the data from $_GET['id'] ?

Or is there any other problem?

 

If you are not passing $groupnumber the the secondary pagination script on the next page loads,then yes, that is the problem. The easiest solutin would be to probably add the groupnumber to the pagination links on the secondary page.

Link to comment
Share on other sites

If you are not passing $groupnumber the the secondary pagination script on the next page loads,then yes, that is the problem. The easiest solutin would be to probably add the groupnumber to the pagination links on the secondary page.

 

Thanks for your reply .

I tried to look at my scripts again and again , but I have really no idea how to pass the groupnumber to next page load...?

 

Here is my code (not yet complete)

<?

$groupnumber = $_GET['id'];

$strSQL = "SELECT * FROM esp WHERE Groupnumber='$groupnumber'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);

$Per_Page = 2;   // Per Page

$Page = $_GET["Page"];
if(!$_GET["Page"])
{
	$Page=1;
}

$Prev_Page = $Page-1;
$Next_Page = $Page+1;

$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
	$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
	$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
	$Num_Pages =($Num_Rows/$Per_Page)+1;
	$Num_Pages = (int)$Num_Pages;
}


$strSQL .=" order  by id DESC LIMIT $Page_Start , $Per_Page";
$objQuery  = mysql_query($strSQL);





?>
<table width="600" border="1">
  <tr>
	<th width="50"> <div align="center">#</div></th>
	<th width="91"> <div align="center">ID </div></th>
	<th width="91"> <div align="center">Groupnumber </div></th>
	<th width="198"> <div align="center">Message </div></th>
	<th width="198"> <div align="center">Create on </div></th>
  </tr>
<?

echo "<form name='form1' method='post' action=''>";

while($objResult = mysql_fetch_array($objQuery))
{


echo "<tr>";
   echo "<td align='center'><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$objResult[id]\"></td>";
   echo "<td>$objResult[id] </td>";
   echo "<td>$objResult[Groupnumber]</td>";
   echo "<td>$objResult[Message] </td>";
   echo "<td>$objResult[mylocaltime] </td>";




echo "</tr>";

}




echo "</form>";

?>
</table>
<br>
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?
if($Prev_Page)
{
           if($_GET["txtFirstName"] == "")
                      {
	echo " <a href='$_SERVER[sCRIPT_NAME]?Page=$Prev_Page&txtLastName=$_GET[txtLastName]'><< Back</a> ";	
                      }

            else
                      {
	echo " <a href='$_SERVER[sCRIPT_NAME]?Page=$Prev_Page&txtFirstName=$_GET[txtFirstName]'><< Back</a> ";
                      }

}

for($i=1; $i<=$Num_Pages; $i++){
	if($i != $Page)
	{

		echo "[ <a href='$_SERVER[sCRIPT_NAME]?Page=$i&txtFirstName=$_GET[txtFirstName]'>$i</a> ]";	

	}
	else
	{
		echo "<b> $i </b>";
	}
}
if($Page!=$Num_Pages)
{
              if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "")
                           {
	        echo " <a href ='$_SERVER[sCRIPT_NAME]?Page=$Next_Page&txtCell=$_GET[txtCell]'>Next>></a> ";	
                           }
              else if($_GET["txtFirstName"] == "" )
                           {
		echo " <a href ='$_SERVER[sCRIPT_NAME]?Page=$Next_Page&txtLastName=$_GET[txtLastName]'>Next>></a> ";	
                           }
              else
                           {
	        echo " <a href ='$_SERVER[sCRIPT_NAME]?Page=$Next_Page&txtFirstName=$_GET[txtFirstName]'>Next>></a> ";	}
                   }

mysql_close($objConnect);





?>

 

So...should I add it somewhere....here??

	if($Page!=$Num_Pages)
{
              if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "")
                           {
	        echo " <a href ='$_SERVER[sCRIPT_NAME]?Page=$Next_Page&txtCell=$_GET[txtCell]'>Next>></a> ";	
                           }
              else if($_GET["txtFirstName"] == "" )
                           {
		echo " <a href ='$_SERVER[sCRIPT_NAME]?Page=$Next_Page&txtLastName=$_GET[txtLastName]'>Next>></a> ";	
                           }
              else
                           {
	        echo " <a href ='$_SERVER[sCRIPT_NAME]?Page=$Next_Page&txtFirstName=$_GET[txtFirstName]'>Next>></a> ";	}
                   }

 

 

Link to comment
Share on other sites

You are getting the $_GET['id']; from the originating page. So, you *should* just need to add that parameter to the links that you create

    if($Page!=$Num_Pages)
    {
        if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "")
        {
            echo " <a href ='$_SERVER[sCRIPT_NAME]?Page=$Next_Page&txtCell=$_GET[txtCell]&id=$groupnumber'>Next>></a> ";	
        }
        else if($_GET["txtFirstName"] == "" )
        {
            echo " <a href ='$_SERVER[sCRIPT_NAME]?Page=$Next_Page&txtLastName=$_GET[txtLastName]&id=$groupnumber'>Next>></a> ";	
        }
        else
        {
            echo " <a href ='$_SERVER[sCRIPT_NAME]?Page=$Next_Page&txtFirstName=$_GET[txtFirstName]&id=$groupnumber'>Next>></a> ";
        }
    }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.