Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submitting form dynamic values

Status
Not open for further replies.

tshey

Technical User
Dec 28, 2005
78
AU
I am passing two values through the url on selection through a dynamic form. However, it is only passing the first value. The selections are in drop down boxes, what am I missing?
Code:
<body>
<div id="findcleaner">
<div id="findhead">Find a Vacuum Cleaner </div>
<div id="findcontent">
  <p>Please select the purpose of your vacuum cleaning needs. </p>
  <form name="form1" id="form1" method="post" action="store_items.php">
    <table>
      
      <?php do { ?>
      <tr>
        <td><a href="find_cleaner.php?cat_id=<?php echo $row_category['cat_id']; ?>"><?php echo $row_category['category']; ?></a></td>
      </tr>
      <?php } while ($row_category = mysql_fetch_assoc($category)); ?>
    </table>
    <p>Please select an area:
      <select name="subcat">
        <?php
do {  
?>
        <option value="<?php echo $row_subcat['subcat_id']?>"<?php if (!(strcmp($row_subcat['subcat_id'], $row_subcat['subcat_id']))) {echo "SELECTED";} ?>><?php echo $row_subcat['subcategory']?></option>
        <?php
} while ($row_subcat = mysql_fetch_assoc($subcat));
  $rows = mysql_num_rows($subcat);
  if($rows > 0) {
      mysql_data_seek($subcat, 0);
	  $row_subcat = mysql_fetch_assoc($subcat);
  }
?>
      </select>
</p>
    
      <p>Please select your cleaning needs:
      <select name="select">
        <?php
do {  
?>
        <option value="<?php echo $row_subcat2['subcat_id']?>"<?php if (!(strcmp($row_subcat2['subcat_id'], $row_subcat2['subcat_id']))) {echo "SELECTED";} ?>><?php echo $row_subcat2['subcat2']?></option>
        <?php
} while ($row_subcat2 = mysql_fetch_assoc($subcat2));
  $rows = mysql_num_rows($subcat2);
  if($rows > 0) {
      mysql_data_seek($subcat2, 0);
	  $row_subcat2 = mysql_fetch_assoc($subcat2);
  }
?>
      </select></p>

      <p><a href="store_items.php?subcat_id=<?php echo $row_subcat['subcat_id']; ?>&subcat2_id=<?php echo $row_subcat2['subcat2_id']; ?>" target="_blank" onClick="window.close();">Submit</a> </p>
  </form>
</div>
</div>

</body>
</html>
<?php
mysql_free_result($category);

mysql_free_result($subcat);

mysql_free_result($subcat2);
?>
 
First, I strongly recommend that you not use do...while loops but instead while loops. Your script is attempting to output array elements that haven't been initialized yet.

Second, I'm not too sure what your two SELECTs are supposed to do, or even why you have a form at all. Your form has no SUBMIT button, only an anchor which will be the only two values submitted. Your form uses the POST method, which means its values, if submitted, will not be from the URL and thus via $_GET, but rather will be in $_POST.

If you are trying to send data by both GET and POST simultaneously, then your HTML needs to be of the form:

<html><body>
<form method="POST" action="somescript.php?somevalue=1&someothervalue=2">
<SELECT name=....">.....</SELECT>
<SELECT naem="...">.....</SELECT>
<INPUT type="submit">
</form></body></html>

This way the values of the two SELECTs can be found in $_POST, but the two other values "somevalue" and "someothervalue" will be found in $_GET.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top