Page 2 of 2

Posted: Wed Jun 09, 2004 12:16 pm
by NewfieBilko
woops, i'll change it to post

Posted: Wed Jun 09, 2004 12:16 pm
by NewfieBilko
NICE, iT WORKS HOMMIE

Posted: Wed Jun 09, 2004 12:17 pm
by NewfieBilko
Now, question... How will I limit the user to only be able to view say, 200 at a time. Should be simple logic

Posted: Wed Jun 09, 2004 12:20 pm
by markl999
Just add another condition to the if line, something like:
&& $_POST['maxRecords'] < 201 ){ ...

You could, i suppose, also use some JavaScript to limit it in the actual input field too but you'll still need the server side check either way.

Posted: Wed Jun 09, 2004 12:24 pm
by NewfieBilko
LOL good point... Nice thinking

Ill stick with my logic /Over java :)

Posted: Wed Jun 09, 2004 12:43 pm
by NewfieBilko
Oh yea, i've run into another little snag... Say i go maxrecords to 100, viewing 100 entries.. Then I hit the "NEXT" link which I have put in &maxRecords={maxRecords}, but instead of showing 100, it will go back to default of 10!!!!... I tried putting this code into my UsersGrid.php:

Code: Select all

<?php
if(isset($_REQUEST["maxRecords"])) {
   $maxRecords == $_REQUEST["maxrecords"]; 
  }
?>
But it doesn't seem to do much.

The maxRecords in the link NEXT does pass 5 as the variable from the last update of max, but when it hit it, it ignores and just goes back to 10. I also noticed my offset is raising by 10 everytime for this regardless

Posted: Wed Jun 09, 2004 12:59 pm
by feyd

Code: Select all

<?php 
if(isset($_REQUEST["maxRecords"])) { 
   $maxRecords = $_REQUEST["maxrecords"]; 
  } 
?>
== for = logic error.. ;)

Posted: Wed Jun 09, 2004 1:02 pm
by jason

Code: Select all

$maxRecords = isset($_REQUEST['maxRecords']) ? $_REQUEST['maxRecords'] : MAX_RECORDS_DEFAULT;

Posted: Wed Jun 09, 2004 1:31 pm
by NewfieBilko
hahaha oh yea

<---- dummie

:oops:

lol thx, got it working great btw.. now to see what the boss wants me to DO with this datagrid system

Posted: Wed Jun 09, 2004 1:52 pm
by NewfieBilko
hmm, sorry,nevermind, it works for the first Click of NEXT, but on the second click, the origional value gets put back into place, showing 10...

in my .php i have :

Code: Select all

<?php
if(isset($_REQUEST["maxRecords"])) {
   $maxRecords = isset($_REQUEST['maxRecords']) ? ($_REQUEST['maxRecords']) : MAX_RECORDS_DEFAULT; 
  }

?>
and in the html of the next I have:

Code: Select all

<?php

{if $prev_offset >= 0}
[<a class="link" href="frmUsersGrid.php?&offset={$prev_offset}&sort_mode={$sort_mode}&maxRecords={$maxRecords}">{tr}PREVIOUS{/tr}</a>]&nbsp;
{/if}
{tr}Page{/tr}: {$actual_page}/{$cant_pages}
{if $next_offset >= 0}
&nbsp;[<a class="link" href="frmUsersGrid.php?&offset={$next_offset}&sort_mode={$sort_mode}&maxRecords={$maxRecords}">{tr}NEXT{/tr}</a>]
{/if}


?>

and finally in my setup.php i have:

Code: Select all

<?php 

if(!empty($_POST['maxRecords']) && ctype_digit($_POST['maxRecords']) && $_POST['maxRecords'] > 0){ 
    $maxRecords = $_POST['maxRecords']; 
} else { 
    $maxRecords = 10; 
} 
$smarty->assign('maxRecords',$maxRecords);
?>

?>
Now, like i said.. I put 5 into the input, works fine, calls 5.. Then i hit next, it shows a maxrecord in the URL of 5, and next is displayed fine.. The 2nd time, it shows this url:

/frmUsersGrid.php?&offset=10&sort_mode=login_desc&maxRecords=10


Its either defaulting back to 10 because there is no holder, OR the offset is triggering it?

Posted: Wed Jun 09, 2004 1:55 pm
by markl999
In your last bit of pasted code try changing $_POST['maxRecords'] to $_REQUEST['maxRecords'] (in all instances)

Posted: Wed Jun 09, 2004 2:12 pm
by NewfieBilko
GOOD THINKING, it works again!!! LOL

SOLVED, SOLVED, SOLVED, SOLVED, SOLVED, SOLVED, SOLVED, SOLVED,