[SOLVED] Smarty: People who are Familiar, I was wo

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

woops, i'll change it to post
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

NICE, iT WORKS HOMMIE
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post 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
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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.
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

LOL good point... Nice thinking

Ill stick with my logic /Over java :)
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

<?php 
if(isset($_REQUEST["maxRecords"])) { 
   $maxRecords = $_REQUEST["maxrecords"]; 
  } 
?>
== for = logic error.. ;)
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Code: Select all

$maxRecords = isset($_REQUEST['maxRecords']) ? $_REQUEST['maxRecords'] : MAX_RECORDS_DEFAULT;
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post 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
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post 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?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

In your last bit of pasted code try changing $_POST['maxRecords'] to $_REQUEST['maxRecords'] (in all instances)
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

GOOD THINKING, it works again!!! LOL

SOLVED, SOLVED, SOLVED, SOLVED, SOLVED, SOLVED, SOLVED, SOLVED,
Post Reply