Jump to content

Comparing Strings


ihsreal

Recommended Posts

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 year later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.