Jump to content

[SOLVED] How to change the value of a variable..???


RRVARMA

Recommended Posts

Hi,

 

I'm new to PHP but tryin hard to learn it..

Here i'm tryin to implement pagination in my web page but am not able to change the variable value whn i click NEXT PAGE link. Please help. A part of the script is shown below.

 


<?php
$ENDING_ROW=$MAX_ROWS;          //This MAX_ROWS is received from previous page. ex., index.php
?>

<INPUT TYPE=HIDDEN name=ENDING_ROW value="<?php echo $MAX_ROWS; ?>">

<FORM name='form1' method=post action=pineapple23.php>
<INPUT TYPE=HIDDEN name=ExcelLink value="off">
<INPUT TYPE=HIDDEN name=MAX_ROWS value="<?php echo $MAX_ROWS; ?>">
<INPUT TYPE=HIDDEN name=start2 value="<?php echo $start2; ?>">
<INPUT TYPE=HIDDEN name=checkbox_same_state value="<?php echo $checkbox_same_state; ?>">
</FORM> 

<?php
if(strtolower($Next2) == "on")
{

$start2= $start2 + $MAX_ROWS;              // start2 is initialized to 1 from the previous page ie, index.php 
$ENDING_ROW= $ENDING_ROW + $MAX_ROWS;

}


.................................
..............................        
.....................................


$query = "select $select_customer
                $select_from_state
                        $select_to_state
			  
           FROM   FRUITS_IMPORTS
          
	  WHERE		$CUSTOMER_NAME_Condition
			    $FROM_STATE_Condition
			    $TO_STATE_Condition


  	        GROUP BY     $group_by_customer
			  $group_by_from_state
                                  $group_by_to_state
			  
			  
qualify row_number() over 
                                          ($group_by_customer
			           $group_by_from_state
                                           $group_by_to_state) between $start2 and $ENDING_ROW";
<?php

.................................
..............................     
.....................................

{
  echo "<CENTER><BODY><align right><A href=\"javascript:this.document.form1.Next2.value='on';this.document.form1.submit();\">NEXT PAGE</A> ";
}

?>          

 

If the MAX_ROWS selected from the previous page is 10, then during the first run the rows shown is from 1 to 10. Then when i click NEXT PAGE it gives me rows from 11 to 20. But after that when i click NEXT PAGE again it gives the same 11 to 20 rows.

 

So, please tell me how to change the values of 'start2' and 'ENDING_ROW' when i click NEXT PAGE.

 

Thanks,

RRVARMA.

 

Link to comment
Share on other sites

Well, the problem is that the the changing of the $start2 variable occurs after the form has been echoed to the browser -- therefore this value always stays the same.

 

You would probably be better off passing all of the variables needed in the URL, however. It would then work for those with javascript turned off too.

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.