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

Forcing line break in repeating region

Community Beginner ,
May 28, 2009 May 28, 2009

Copy link to clipboard

Copied

I've got a table that's displaying some data from a query in PHP that I made using a simple Recordset and Repeat Region behavior.  I would really like to be able to break the table up (add blank row) each time a certain field changes values.  My code (or the code DW gave me) is as follows.

  <?php do { ?>

      <tr bgcolor="#809E7C" class="reg_dataview_data">

        <td>  </td>

        <td><?php echo $row_rs_Sum09['ChildFirst']; ?></td>

        <td><?php echo $row_rs_Sum09['ChildAge']; ?></td>

        <td><?php echo $row_rs_Sum09['ChildSex']; ?></td>

        <td><?php echo $row_rs_Sum09['Session']; ?></td>

        <td><?php echo $row_rs_Sum09['Status']; ?></td>

        <td><?php echo $row_rs_Sum09['Quarter']; ?></td>

      </tr>

      <?php } while ($row_rs_Sum09 = mysql_fetch_assoc($rs_Sum09)); ?>

I'd like for the table to break at change in value of Session.

Any tips would be greatly appreciated.

Steve

TOPICS
Server side applications

Views

886
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

correct answers 1 Correct answer

LEGEND , May 30, 2009 May 30, 2009

Yes, sorry about that. Simple mistake. I forgot to reset the value each time the loop runs:

      <?php // get the initial value of session
      $currentSession = $row_rs_Sum09['Session'];
      do {
      // create empty row if session is different
      if ($row_rs_Sum09['Session'] != $currentSession) {
      ?>
      <tr><td colspan="7"> </td></tr>
      <?php } ?>
      <tr bgcolor="#809E7C" class="reg_dataview_data">
        <td>  </td>
        <td><?php echo $row_rs_Sum09['ChildFirst']; ?></td>
     
...

Votes

Translate
Advisor ,
May 28, 2009 May 28, 2009

Copy link to clipboard

Copied

Whatever you put in the repeat region will be repeated. Add a conditional region if field changed show break else.

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 ,
May 28, 2009 May 28, 2009

Copy link to clipboard

Copied

I'm afraid I'm not good at PHP, I just tweak what DW makes for me here and there so is there somewhere you can point me that has examples of what I'm trying to do?  I tried searching Google but am having trouble finding what I need.  I dont' suppose DW has this functionality built in?

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
Advisor ,
May 28, 2009 May 28, 2009

Copy link to clipboard

Copied

for conditional region look here

also check out http://php.net

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 ,
May 28, 2009 May 28, 2009

Copy link to clipboard

Copied

You need to create a variable to compare the value of Session with the existing one.

      <?php // get the initial value of session

      $currentSession = $row_rs_Sum09['Session'];

      do {

      // create empty row if session is different

      if ($row_rs_Sum09['Session'] != $currentSession) {

      ?>

      <tr><td colspan="7"> </td></tr>

      <?php } ?>

      <tr bgcolor="#809E7C" class="reg_dataview_data">

        <td>  </td>

        <td><?php echo $row_rs_Sum09['ChildFirst']; ?></td>

        <td><?php echo $row_rs_Sum09['ChildAge']; ?></td>

        <td><?php echo $row_rs_Sum09['ChildSex']; ?></td>

        <td><?php echo $row_rs_Sum09['Session']; ?></td>

        <td><?php echo $row_rs_Sum09['Status']; ?></td>

        <td><?php echo $row_rs_Sum09['Quarter']; ?></td>

      </tr>

      <?php } while ($row_rs_Sum09 = mysql_fetch_assoc($rs_Sum09)); ?>

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 ,
May 28, 2009 May 28, 2009

Copy link to clipboard

Copied

Hi David.  Thank you.  It's much closer now.  I get a blank row after the first grouping of Sessions of the same value as expected, then every row after that has one row of data, and a blank below it, regardless of if the Session value is the same or not, like it's not checking the variable after the first run through?  See attached file...

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 ,
May 30, 2009 May 30, 2009

Copy link to clipboard

Copied

Yes, sorry about that. Simple mistake. I forgot to reset the value each time the loop runs:

      <?php // get the initial value of session
      $currentSession = $row_rs_Sum09['Session'];
      do {
      // create empty row if session is different
      if ($row_rs_Sum09['Session'] != $currentSession) {
      ?>
      <tr><td colspan="7"> </td></tr>
      <?php } ?>
      <tr bgcolor="#809E7C" class="reg_dataview_data">
        <td>  </td>
        <td><?php echo $row_rs_Sum09['ChildFirst']; ?></td>
        <td><?php echo $row_rs_Sum09['ChildAge']; ?></td>
        <td><?php echo $row_rs_Sum09['ChildSex']; ?></td>
        <td><?php echo $row_rs_Sum09['Session']; ?></td>
        <td><?php echo $row_rs_Sum09['Status']; ?></td>
        <td><?php echo $row_rs_Sum09['Quarter']; ?></td>
      </tr>
      <?php
      // update the value of $currentSession
      $currentSession = $row_rs_Sum09['Session'];
      } while ($row_rs_Sum09 = mysql_fetch_assoc($rs_Sum09)); ?>

By the way, attaching images is very hit and miss in this forum. It's much better to use the camera icon at the top of the message field to embed the image directly in your post.

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 ,
May 30, 2009 May 30, 2009

Copy link to clipboard

Copied

LATEST

Thanks David as always!  That did the trick.  I'll remember the camera icon for next time too.

Steve

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