3 Replies Latest reply: Jul 23, 2007 2:50 AM by Newsgroup_User RSS

    SEARCH AND RESULT IN THE SAME PAGE

    oicram Community Member
      Hi,

      Using: mySQL, PHP, DW

      As I have the results appearing on the same page as search function, the show if recordset is empty will not properly work, since the "No Records Match Your Criteria" message will appear as soon as you open the page.

      how do I get this message to only show after the user have searched?

      Hope someone can point me out a solution for this,
      MEM
        • 1. Re: SEARCH AND RESULT IN THE SAME PAGE
          Newsgroup_User Community Member
          oicram wrote:
          > As I have the results appearing on the same page as search function, the show
          > if recordset is empty will not properly work, since the "No Records Match Your
          > Criteria" message will appear as soon as you open the page.

          This is a failing of the way the Show if recordset is empty server
          behavior, but it's easy to remedy.

          > how do I get this message to only show after the user have searched?

          The code as inserted by Dreamweaver looks like this (recordsetName will
          be replaced by whatever name you gave your recordset):

          <?php if ($totalRows_recordsetName == 0) { // Show if recordset empty ?>

          Change it like this:

          <?php if (array_key_exists('submitButtonName', $_POST) &&
          $totalRows_recordsetName == 0) { // Show if recordset empty ?>

          Replace submitButtonName with the name of the submit button in your
          search form. That's all there is to it.

          --
          David Powers, Adobe Community Expert
          Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
          Author, "PHP Solutions" (friends of ED)
          http://foundationphp.com/
          • 2. Re: SEARCH AND RESULT IN THE SAME PAGE
            oicram Community Member

            <?php if (array_key_exists('submitButtonName', $_POST) &&
            $totalRows_recordsetName == 0) { // Show if recordset empty ?>

            Thanks a lot. Its precious to know php at least make a if with a nice array_key_exists. :)

            I have change the $_POST to $_GET since my form is getting, and it works perfectly.

            Thanks a lot.
            • 3. Re: SEARCH AND RESULT IN THE SAME PAGE
              Newsgroup_User Community Member
              oicram wrote:
              > I have change the $_POST to $_GET since my form is getting, and it works
              > perfectly.

              Glad to have been of help.

              --
              David Powers, Adobe Community Expert
              Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
              Author, "PHP Solutions" (friends of ED)
              http://foundationphp.com/