10 Replies Latest reply on Aug 3, 2007 9:32 AM by destind4film

    Dynamic Repeating Region - how to remove blank fields

    destind4film
      I have a results page that displays a simple contact DB search results. This page has a repeating region based on dynamic text fields for the contact, address, city, state, zip and phone.

      The problem is that sometimes there is only a contact name and phone in the record in mySql. In these cases, I do not want to have 4 blank spaces for the missing address, city, state and zip.

      Is there a php script I can use that would ignore the text holders if they are null in the DB?
        • 1. Re: Dynamic Repeating Region - how to remove blank fields
          Level 7

          "destind4film" <webforumsuser@macromedia.com> wrote in message
          news:f8qjdf$aeu$1@forums.macromedia.com...
          >I have a results page that displays a simple contact DB search results.
          >This
          > page has a repeating region based on dynamic text fields for the contact,
          > address, city, state, zip and phone.
          >
          > The problem is that sometimes there is only a contact name and phone in
          > the
          > record in mySql. In these cases, I do not want to have 4 blank spaces for
          > the
          > missing address, city, state and zip.
          >
          > Is there a php script I can use that would ignore the text holders if they
          > are
          > null in the DB?

          You could select, say the comma and space before a field entry plus the
          field entry and then use the Show Region SB - probably the "show region if
          recordset is not empty". that might do the trick


          • 2. Re: Dynamic Repeating Region - how to remove blank fields
            Level 7
            destind4film wrote:
            > Is there a php script I can use that would ignore the text holders if they are
            > null in the DB?

            <?php if (!empty($row_recordsetName['fieldName'])) echo
            $row_recordsetName['fieldName']; ?>

            --
            David Powers, Adobe Community Expert
            Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
            Author, "PHP Solutions" (friends of ED)
            http://foundationphp.com/
            • 3. Re: Dynamic Repeating Region - how to remove blank fields
              destind4film Level 1
              Hi David,

              Thanks again for your fast replies and all of your help! I really appreciate it.

              So I tried doing this both ways, I went into the code and added the if empty statement as you instructed, but the problem still persisted.

              I also tried Hunter's method by assigning the SB of show if to each field and that didn't work either.

              Here is the current code for the repeating region with the SB attached, if that helps:

              I also checked the mySQL DB and the fields in questions allow for NULL values.
              • 4. Re: Dynamic Repeating Region - how to remove blank   fields
                Level 7
                destind4film wrote:
                > I also tried Hunter's method by assigning the SB of show if to each field and
                > that didn't work either.

                Using the Show If Recordset Not Empty server behavior won't work in a
                month of Sundays. It checks if the recordset is empty, not whether a
                particular field is empty.

                Show me how you attempted to do it with the code that I suggested.

                --
                David Powers, Adobe Community Expert
                Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
                Author, "PHP Solutions" (friends of ED)
                http://foundationphp.com/
                • 5. Re: Dynamic Repeating Region - how to remove blank   fields
                  Level 7

                  "David Powers" <david@example.com> wrote in message
                  news:f8qvsf$p1i$1@forums.macromedia.com...
                  > destind4film wrote:
                  >> I also tried Hunter's method by assigning the SB of show if to each
                  >> field and that didn't work either.
                  >
                  > Using the Show If Recordset Not Empty server behavior won't work in a
                  > month of Sundays. It checks if the recordset is empty, not whether a
                  > particular field is empty.

                  sorry, David - I thought I'd tried that and it worked.... I must've been
                  thinking of something else. Sorry for the bad info!


                  • 6. Re: Dynamic Repeating Region - how to remove blank   fields
                    Level 7

                    "Hunter Elliott" <nospam@gatewaycity.com> wrote in message
                    news:f8smte$r7p$1@forums.macromedia.com...
                    >
                    > "David Powers" <david@example.com> wrote in message
                    > news:f8qvsf$p1i$1@forums.macromedia.com...
                    >> destind4film wrote:
                    >>> I also tried Hunter's method by assigning the SB of show if to each
                    >>> field and that didn't work either.
                    >>
                    >> Using the Show If Recordset Not Empty server behavior won't work in a
                    >> month of Sundays. It checks if the recordset is empty, not whether a
                    >> particular field is empty.
                    >
                    > sorry, David - I thought I'd tried that and it worked.... I must've been
                    > thinking of something else. Sorry for the bad info!

                    d'oh! I know what I was thinking of now. I've used DMXzone's Advanced
                    Conditional Region server behavior. It basically creates little if/then
                    statements like this:
                    <% if rsRecordset.Fields.Item("FieldName").Value <> "" then %>
                    <%=(rsRecordset.Fields.Item("FieldName").Value)%>
                    <% end if %>


                    • 7. Re: Dynamic Repeating Region - how to remove blank   fields
                      Level 7
                      Hunter Elliott wrote:
                      > d'oh! I know what I was thinking of now. I've used DMXzone's Advanced
                      > Conditional Region server behavior. It basically creates little if/then
                      > statements like this:
                      > <% if rsRecordset.Fields.Item("FieldName").Value <> "" then %>
                      > <%=(rsRecordset.Fields.Item("FieldName").Value)%>
                      > <% end if %>

                      Yes, that makes sense. The Dreamweaver built-in SB checks only if the
                      recordset is empty, not an individual field.

                      --
                      David Powers, Adobe Community Expert
                      Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
                      Author, "PHP Solutions" (friends of ED)
                      http://foundationphp.com/
                      • 8. Re: Dynamic Repeating Region - how to remove blank   fields
                        destind4film Level 1
                        Hi David,

                        Sorry for the long delay in responding to this. Been busy trying to finish up lots of other stuff on this site...But I went ahead and tried redoing this by hand coding as you suggested. You can also take a look at the results in a browser to see what I mean, choose any of the first four selections in the search menu to see the output:

                        http://www.dvdflashbacks.com/williamsburghealth/index.php

                        So here is the code for my blank spaces problem.

                        Thanks again for all your help and support. I have read over the entire book one time and made my way through to chapter 12 doing all of the exercises. Great stuff! A lot to learn...but it is a very good book. I have been referring to different examples for the last few days as I work through this new project!

                        • 9. Re: Dynamic Repeating Region - how to remove blank     fields
                          Level 7
                          destind4film wrote:
                          > So here is the code for my blank spaces problem.

                          The answer is so simple, you're going to kick yourself. You have
                          inserted the conditional statements correctly, but the <br /> tags are
                          outside them, so they always get inserted into the page. The <br /> tags
                          must be part of the conditional statement, too. Put them before each
                          item, instead at the end of the preceding one. That way, you will get a
                          line break only when one is actually needed. I have also removed the PHP
                          tags around every line. They do no harm, but they make the code more
                          difficult to read. Dreamweaver inserts them automatically around dynamic
                          text because it has no idea where you're going to place it. Since the
                          database results are displayed as a single block, you need the tags only
                          at the beginning and end of the block.

                          <?php do { ?>
                          <p>
                          <?php echo $row_directoryResults['clinicName'];
                          if (!empty($row_directoryResults['doctorName']))
                          echo '<br />'.$row_directoryResults['doctorName'];
                          if (!empty($row_directoryResults['clinicAddress']))
                          echo '<br />'.$row_directoryResults['clinicAddress'];
                          if (!empty($row_directoryResults['clinicCity']))
                          echo '<br />'.$row_directoryResults['clinicCity'];
                          if (!empty($row_directoryResults['clinicState']))
                          echo '<br />'.$row_directoryResults['clinicState'];
                          if (!empty($row_directoryResults['clinicZip']))
                          echo '<br />'.$row_directoryResults['clinicZip'];
                          echo '<br />'.$row_directoryResults['clinicPhone']; ?>
                          </p>
                          <?php } while ($row_directoryResults =
                          mysql_fetch_assoc($directoryResults)); ?>

                          --
                          David Powers, Adobe Community Expert
                          Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
                          Author, "PHP Solutions" (friends of ED)
                          http://foundationphp.com/
                          • 10. Re: Dynamic Repeating Region - how to remove blank     fields
                            destind4film Level 1
                            Can I be your apprentice? you are the Jedi Master!!!