ihsreal Posted February 21, 2007 Share Posted February 21, 2007 This code compares a drop down list with the users selections as stored in their property(house) data record. The problem I'm having is that when 2 or more descriptive fields begin with the same string, they are all selected even if only one of the selections are in the database (i.e. with the choices 'brick', 'brick and frame', 'brick siding' choosing just 'brick siding' also selects 'brick' when the page is loaded). How would I change this so that only 'brick siding' is selected in the example. <select name="extConst[]" size="5" multiple="multiple" id="extConst[]"> <option value="" >Make Selection(s)</option> <?php do { ?> <option value="<?php echo $row_rsExtConst['extConstDesc']?>"<?php if ((strpos( $row_rsProperty['extConst_prp'],$row_rsExtConst['extConstDesc']))!==false) {echo "SELECTED";} ?>><?php echo $row_rsExtConst['extConstDesc']?></option> <?php } while ($row_rsExtConst = mysql_fetch_assoc($rsExtConst)); $rows = mysql_num_rows($rsExtConst); if($rows > 0) { mysql_data_seek($rsExtConst, 0); $row_rsExtConst = mysql_fetch_assoc($rsExtConst); } ?> </select> Thanks for any help here. Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted February 21, 2007 Share Posted February 21, 2007 If you give each $row_rsExtConst['$k'], a separate id Key possibly in a 3D array, then you can post that id number with value="<?php echo $row_rsExtConst['extConstDesc'][0]?>" Which will return the unique id number so the script doesn't get confused. Hope that makes sense Quote Link to comment Share on other sites More sharing options...
ihsreal Posted February 21, 2007 Author Share Posted February 21, 2007 Thanks, that does make sense, but I don't know how to do it. Here's what I did to solve the problem. I changed the name of the 'brick' to 'brick - all' and now it works correctly. I would have liked to find a solution that would compare the strings and selects only the selections where the entire string matched. Whatever works I guess. Quote Link to comment Share on other sites More sharing options...
RalphOrange Posted April 23, 2008 Share Posted April 23, 2008 I have read the message thread, but I am still a little confused. Would someone be able to explain why this worked? thanks....http://www.ezmlslisting.com 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.