2 Replies Latest reply on Dec 19, 2008 3:10 PM by Rudei

    PHP Problem

    Rudei Level 1
      Hi,

      Im trying to incorporate the bottom search into the top bit of code. Originally, i would go straight to a link, but now decided to use a session variable rather than storing the value in the URL, so i have the same method as the search,

      but stuck on how to get the maindb.php to be called once the drop down is selected. i think the problem lies in the form declaration, but not sure.

      <form name="form1" method="POST" action="maindb.php">
      <div align="left">
      <img src="./Images/link.gif" alt="Link" width="113" height="27">
      <select name="select1" size="1" OnChange="jumptolink(document.form1.select1)">
      <option value="#"><b>Please Select...</b></option>
      <?php

      mysql_connect(.....) or die(mysql_error());
      mysql_select_db("....") or die(mysql_error());

      $result3 = mysql_query("SELECT * FROM tes order by value" )
      or die(mysql_error());

      while($row3 = mysql_fetch_array( $result3 ))
      {
      echo "<option value=\"";
      echo $row3['idkey'];
      echo "\" id=\"";
      echo "test";
      echo "\"> ";
      echo $row3['value'];
      echo "</option>\n";
      }
      echo "</select>\n";
      echo "</div>\n";
      echo "</form>\n";

      ?>
      </form>

      <form method="POST" action="mainsearch.php">
      Search:<br />
      <input type="text" id="keyword" name="keyword" /><br />
      <input type="submit" value="Search!" />
      </form>

        • 1. Re: PHP Problem
          Level 7
          Rudei wrote:
          > Hi,
          >
          > Im trying to incorporate the bottom search into the top bit of code.
          > Originally, i would go straight to a link, but now decided to use a session
          > variable rather than storing the value in the URL, so i have the same method as
          > the search,
          >
          > but stuck on how to get the maindb.php to be called once the drop down is
          > selected. i think the problem lies in the form declaration, but not sure.
          >
          > <form name="form1" method="POST" action="maindb.php">
          > <div align="left">
          > <img src="./Images/link.gif" alt="Link" width="113" height="27">
          > <select name="select1" size="1" OnChange="jumptolink(document.form1.select1)">
          > <option value="#"> Please Select...</option>
          > <?php
          >
          > mysql_connect(.....) or die(mysql_error());
          > mysql_select_db("....") or die(mysql_error());
          >
          > $result3 = mysql_query("SELECT * FROM tes order by value" )
          > or die(mysql_error());
          >
          > while($row3 = mysql_fetch_array( $result3 ))
          > {
          > echo "<option value=\"";
          > echo $row3['idkey'];
          > echo "\" id=\"";
          > echo "test";
          > echo "\"> ";
          > echo $row3['value'];
          > echo "</option>\n";
          > }
          > echo "</select>\n";
          > echo "</div>\n";
          > echo "</form>\n";
          >
          > ?>
          > </form>
          >
          > <form method="POST" action="mainsearch.php">
          > Search:<br />
          > <input type="text" id="keyword" name="keyword" /><br />
          > <input type="submit" value="Search!" />
          > </form>
          >
          >
          >
          You're missing the "jumptolink" function definition.
          BTW: It's often better to show the generated HTML.
          BTW2: I would not submit the form as a response to the onchange event of
          the select menu(The punter may have accidentally selected the wrong value)
          You could do something like the following:

          onchange=
          'if(confirm("Are you sure you want "+this.value+"?"))
          this.form.submit();'


          To accommodate those without js:
          <noscript><input type="submit" value="GO"></noscript>

          Mick
          • 2. Re: PHP Problem
            Rudei Level 1
            Thanks, worked a treat. Thanks for advice also.