2 Replies Latest reply on Feb 22, 2011 8:36 PM by George S.

    Query with search field in CS5

    George S.

      I have recently upgraded to CS5.  In CS3, I developed several pages where there was a form where the user entered on search parameter, executed the query using the form method get and the results were displayed on the same page in a recordset.

       

      In CS5, I have used the same concept to build a search page but for some reason, I cannot get the results to appear.  I have compared the CS5 to the CS3 code and cannot find any differences.  I have attached my php page.  If anyone has any ideas, I would appreciate it.  I suspect it is something simple but cannot determine what it is.

       

      Thanks.  George

      http://www.cfoclinic.org/admin/regusers.php

       

      $colname_Record = "-1";
      if (isset($GET_['input_year'])) {
        $colname_Record = $GET_['input_year'];
      }
      mysql_select_db($database_cfouser, $cfouser);
      $query_Record = sprintf("SELECT * FROM CFO_Registration WHERE YEAR = %s and active = 'Y' ORDER BY Reg_id", GetSQLValueString($colname_Record, "text"));
      $query_limit_Record = sprintf("%s LIMIT %d, %d", $query_Record, $startRow_Record, $maxRows_Record);
      $Record = mysql_query($query_limit_Record, $cfouser) or die(mysql_error());
      $row_Record = mysql_fetch_assoc($Record);

      if (isset($_GET['totalRows_Record'])) {
        $totalRows_Record = $_GET['totalRows_Record'];
      } else {
        $all_Record = mysql_query($query_Record);
        $totalRows_Record = mysql_num_rows($all_Record);
      }
      $totalPages_Record = ceil($totalRows_Record/$maxRows_Record)-1;
      ?>

      --- note  code skips ahead to following

      <form action="" method="get" name="Search" class="black11b" id="Search">
        <p> </p>
        <table width="386" border="1" align="center" class="black14b" id="table1">
          <tr>
            <th width="162" height="39" scope="col"><p>
              <input type="submit" name="Search" id="Submit" value="Execute">
            </p>
              <p>
                <input type="reset" name="reset" id="reset" value="Reset">
              </p></th>
            <th width="208" scope="col"><input name="input_year" type="text" id="year" size="4" maxlength="4"> <label for="input_year">Clinic Year</label></th>
          </tr>
          </table>
        <br>
      </form>

        • 1. Re: Query with search field in CS5
          Günter Schenk Level 4

          Right now your form´s "action" attribute is empty, so the data is going nowhere.

           

          As you want the very same page to process the form data, please try with:

           

          action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"

           

          Cheers,

          Günter

           

          P.S. As your question is not related to the (discontinued) Dreamweaver Development Toolbox extension, please post further Dreamweaver & PHP questions in the regular Dreamweaver Application Development forum.

          • 2. Re: Query with search field in CS5
            George S. Level 1

            Gunter,

            Unfortunately, it did not work.  I am re-attaching my code.  In addition to your comment, I added the first line listed below.

             

            Do you have any other suggestions?

             

            Thanks.  George

            $editFormAction = $_SERVER['PHP_SELF'];

            $maxRows_Record = 10;
            $pageNum_Record = 0;
            if (isset($_GET['pageNum_Record'])) {
              $pageNum_Record = $_GET['pageNum_Record'];
            }
            $startRow_Record = $pageNum_Record * $maxRows_Record;

            $colname_Record = "-1";
            if (isset($GET_['input_year'])) {
              $colname_Record = $GET_['input_year'];
            }
            mysql_select_db($database_cfouser, $cfouser);
            $query_Record = sprintf("SELECT * FROM CFO_Registration WHERE YEAR = %s and active = 'Y' ORDER BY Reg_id", GetSQLValueString($colname_Record, "text"));
            $query_limit_Record = sprintf("%s LIMIT %d, %d", $query_Record, $startRow_Record, $maxRows_Record);
            $Record = mysql_query($query_limit_Record, $cfouser) or die(mysql_error());
            $row_Record = mysql_fetch_assoc($Record);

            if (isset($_GET['totalRows_Record'])) {
              $totalRows_Record = $_GET['totalRows_Record'];
            } else {
              $all_Record = mysql_query($query_Record);
              $totalRows_Record = mysql_num_rows($all_Record);
            }
            $totalPages_Record = ceil($totalRows_Record/$maxRows_Record)-1;
            ?>

             

            <form action="<?php echo $editFormAction; ?> " method="get" name="Search" target="_self" class="black11b" id="Search">
              <p> </p>
              <table width="386" border="1" align="center" class="black14b" id="table1">
                <tr>
                  <th width="162" height="39" scope="col"><p>
                    <input type="submit" name="Search" id="Submit" value="Execute">
                  </p>
                    <p>
                      <input type="reset" name="reset" id="reset" value="Reset">
                    </p></th>
                  <th width="208" scope="col"><input name="input_year" type="text" id="year" size="4" maxlength="4"> <label for="input_year">Clinic Year</label></th>
                </tr>
                </table>
              <br>
            </form>