Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

CS5.5 want to change the number records returned for a repeat region from user input

Community Beginner ,
Mar 17, 2014 Mar 17, 2014

Copy link to clipboard

Copied

Hello,

I am looking to allow the user to set the number of rows returned in a repeat region from the fixed amount set using Server Behaviours to a figure set by the person viewing the page.

I have seen that the code generated uses:

$maxRows_rsVenues = 20;

To start with I thought something simple. Either all records or the preset 20 rows at a time. I presume SESSION variables would be a good way to go so setting a form on the page with a checkbox (checked meaning ALL and unchecked for 20). (It gets me into how the coding works)

Having googled my requirement and read responses on using checkboxes and session variables I had the following theory

At start of page make sure session value exists:

if (!isset($_SESSION))

{

          session_start();

}

$_SESSION['listcount']='20';

In the body before the table created within the repeat region put

    <form id="form1" name="form1" method="post" action="">

      <p id="frmFilter">

        <input name="SeeAll" type="checkbox" id="SeeAll" value="1" />

        <label for="SeeAll">SeeAll</label>

        <input type="submit" name="Set Filter" id="Set Filter" value="Set Filter" />

      </p>

    </form>

    <?php

                    if (isset($_POST['Submit'])) {

                              if ($_POST['SeeAll'] == '1')

                              {

                                  $_SESSION['venuelistcount'] = '999999';

                              } else {

                                  $_SESSION['venuelistcount'] = '20';

                              }

  }

?>

<?php echo "LIST COUNT: ".$_SESSION['venuelistcount']; ?>

The problem is the Session variable never seems to be modified. Can someone explain what I have misunderstood, or perhaps a better option to implement what I want.

Thanks

TOPICS
Server side applications

Views

745
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 17, 2014 Mar 17, 2014

Copy link to clipboard

Copied

>    if (isset($_POST['Submit'])) {

Your form has no elements named 'Submit' so it will never get past the first IF statement.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 18, 2014 Mar 18, 2014

Copy link to clipboard

Copied

Thanks that was my misunderstanding of the $_POST. I have got it to remember the state now.

I have this code inserted at the begining of the CS5.5 generated code

     <?php require_once('../Connections/dbconn.php'); ?>

     <?php

     if (!isset($_SESSION))

     {

               session_start();

               $_SESSION['listcount']='20';

     }

......

then later replace the rhside of an assignement to use the session variable

...

     $totalRows_rsVenues = mysql_num_rows($rsVenues);

     $maxRows_rsVenues = $_SESSION['venuelistcount'];

     $pageNum_rsVenues = 0;

....

and code in a form to set the session variable

....

    <form id="form1" name="form1" method="post" action="">

      <p id="frmFilter">

        <input name="SeeAll" type="checkbox" id="SeeAll" value="1" />

        <label for="SeeAll">SeeAll</label>

        <input type="submit" name="SetFilter" id="SetFilter" value="Set Filter" />

      </p>

    </form>

    <?php

                    if (isset($_POST['SetFilter'])) {

                              if ($_POST['SeeAll'] == '1')

                              {

                                  $_SESSION['listcount'] = '999999';

                              } else {

                                  $_SESSION['listcount'] = '20';

                              }

                    }

?>

<?php echo "LIST COUNT: ".$_SESSION['listcount']; ?>

But how do I trigger the CS5.5 code to redraw the data with the new values. Or should I not bother with the generated code and do it all in php manually?

Kerry

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 18, 2014 Mar 18, 2014

Copy link to clipboard

Copied

But how do I trigger the CS5.5 code to redraw the data with the new values.

What do you mean by 'redraw the data'?

Or should I not bother with the generated code and do it all in php manually?


I think your best bet is to code this by hand. DW's generated code is badly outdated and overly complex. In addition, once you start making changing to the generated code, it breaks the connection to the server behaviors and then DW has a tendency to duplicate the code.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 20, 2014 Mar 20, 2014

Copy link to clipboard

Copied

LATEST

I'll look at doing this manually. Thanks for the input.

Redraw comes from C# parlance when working on a large DB project. It refers to "re-drawing the data from DB tables into a db object/query. I know the same phrase is used elsewhere and I have to remind myself which environment I'm in sometimes to make sure I am using the same "dictionary" as those around me. I don't always succeed.

Thanks

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines