MaxBodine Posted December 5, 2007 Share Posted December 5, 2007 I have populated a dropdown list in Dreamweaver, which loads fine, but it is passing the first item of the list, not the selected one. Not sure why? ??? In a time crunch, Thanks for any help! <? mysql_select_db($database_connJDD, $connJDD); $query_rsSKU = "SELECT products.SKU FROM products"; $rsSKU = mysql_query($query_rsSKU, $connJDD) or die(mysql_error()); $row_rsSKU = mysql_fetch_assoc($rsSKU); $totalRows_rsSKU = mysql_num_rows($rsSKU); ?> <table align="center"> <tr> <td> <p align="center">Select SKU for <br /> Update Product </p> <form id="form5" name="form5" method="post" action="updateProducts.php?ProductNo=<?php echo $row_rsSKU['SKU']; ?>"> <select name="skuList"> <?php do { ?> <option value="<?php echo $row_rsSKU['SKU']?>"<?php if (!(strcmp($row_rsSKU['SKU'], $row_rsSKU['SKU']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsSKU['SKU']?></option> <?php } while ($row_rsSKU = mysql_fetch_assoc($rsSKU)); $rows = mysql_num_rows($rsSKU); if($rows > 0) { mysql_data_seek($rsSKU, 0); $row_rsSKU = mysql_fetch_assoc($rsSKU); } ?> </select> <br /> <input name="Update" type="submit" value="Update" /> </form> </td> </tr> </table> <?php mysql_free_result($rsSKU); ?> Quote Link to comment Share on other sites More sharing options...
saadshams Posted December 30, 2007 Share Posted December 30, 2007 Perhaps few questions from your code will help you to reach to your solution. 1) Why action="updateProducts.php?ProductNo=<?php echo $row_rsSKU['SKU']; ?> has ProductNo=<?php..... has been hardcoded. It will always be the first value passed to updateProducts.php page. Remove this parameter 2) If you are examining values at address bar, note your form action is set to POST. If updateProducts.php is extracting value using GET method, set the method to GET. 3) While populating your select Menu, you have chosen "Select value equal to" and the $row_rsSKU['SKU'], thats why its comparing values <?php if (!(strcmp($row_rsSKU['SKU' .... (remove that). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.