RRVARMA Posted May 18, 2008 Share Posted May 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted May 18, 2008 Share Posted May 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
RRVARMA Posted May 19, 2008 Author Share Posted May 19, 2008 Hi Ben, Thank you very much.. I got it.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.