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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

another problem with ampersand

Status
Not open for further replies.

bigbird3156

Programmer
Feb 20, 2001
183
0
0
AU
I have created an edit record page that has two dropdown menus in it that are populated by another recordset in the database...

when they are populated they display the stored value of the record as the default unless that value has a special character(case in point a designer by the name of 'melly & me')... if it does have a special char then it displays the first value in the database

can anyone give me any ideas of how to fix the following code so that it will recognise the special characters when it is selecting the default value
Code:
<select name="designer">
        <?php 
do {  
?>
        <option value="<?php echo $row_designer_files['designer']?>" <?php if (!(strcmp($row_designer_files['designer'], htmlentities($row_edit_products['designer'], ENT_COMPAT, 'utf-8')))) {echo "SELECTED";} ?>><?php echo $row_designer_files['designer']?></option>
        <?php
} while ($row_designer_files = mysql_fetch_assoc($designer_files));
?>
      </select>

The Bird from Down Under- Bigbird 3156 [upsidedown]
 
Hi

I think it should be like this, so use the [tt]htmlentities()[/tt] for the values output into the HTML document and not for the compared terms :
Code:
<select name="designer">
<?php

do {  

?>
  <option value="<?php echo htmlentities($row_designer_files['designer'],ENT_COMPAT,'utf-8'); ?>"<?php if (!strcmp($row_designer_files['designer'],$row_edit_products['designer'])) echo ' selected="selected"'; ?>><?php echo htmlentities($row_designer_files['designer'],ENT_COMPAT,'utf-8'); ?></option>
<?php

} while ($row_designer_files = mysql_fetch_assoc($designer_files));

?>
</select>

Feherke.
 
Thanks heaps! that did the trick!

The Bird from Down Under- Bigbird 3156 [upsidedown]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top