Source: http://www.ido321.com/1189.html
Yesterday, I encountered an abnormal option display in the project. The screenshot is as follows:
The effect after using css control in Firefox
css does not work in chrome and IE
Code:
<div class="controls"> <select name="ksname" id="ksname"> <?php while (!!$rowDK = fetchAssoc($resultDK)) { ?> <optgroup label="<?php echo $rowDK['name']; ?>"> <?php $resultKS = queryDB("select table_dake.id,table_keshi.sid,table_keshi.name from table_dake,table_keshi where table_dake.name='{$rowDK['name']}' and table_keshi.sid=table_dake.id"); while(!!$rowKS = fetchAssoc($resultKS)) { ?> <option value ="<?php echo $rowKS['name']; ?>"><?php echo $rowKS['name']; ?></option> <?php </optgroup> } } free($resultDK); free($resultKS); ?> </select> </div>
After debugging for a long time, I also looked for methods on the Internet, but in the end to no avail, I just asked the experts for advice. Daniel suggested that I check the source code. Has the style changed? The select part of this code does not have any style, how come there are so many? After reading the source code, there are indeed not many styles, but there is an extra after each option. After looking back at the code, I realized that I wrote in the inner loop. According to my The logic should be placed in the outer loop. After adjustment, everything is normal.
So, there is another way to debug the code: view the original code
Next article: 90 IT communities are waiting for you to choose! !
Summary of select option exceptions