Xtremer360 Posted September 30, 2010 Share Posted September 30, 2010 Anything wrong with this because I got a parse error ONLY after adding to create this. <?php $visible = array('Yes', 'No'); foreach($visible as $visible): $visible2 = array('yes', 'no'); foreach($visible2 as $visible2): ?> Link to comment https://forums.phpfreaks.com/topic/214854-for-each-statements/ Share on other sites More sharing options...
Xtremer360 Posted September 30, 2010 Author Share Posted September 30, 2010 Here's the whole select tag. The idea is to have the value of the options be yes and no but for it to show Yes and No to the user to select either. <select name="visible" class="dropdown"> <option value="0">- Select -</option> <?php $visible = array('Yes', 'No'); foreach($visible as $visible): $visible2 = array('yes', 'no'); foreach($visible2 as $visible2): ?> <option value="<?php echo $visible2; ?>"<?php if($visible == $row['visible']): echo ' SELECTED'; endif; ?>><?php echo $visible; ?></option> <?php endforeach; ?> </select> Link to comment https://forums.phpfreaks.com/topic/214854-for-each-statements/#findComment-1117706 Share on other sites More sharing options...
Pawn Posted September 30, 2010 Share Posted September 30, 2010 $options = array( // option_val => display_text "yes" => "Yes", "no" => "No" ); foreach($options as $key => $val) { echo "<option value=\"".$key."\""; if($key == $row['visible']) echo " selected=\"selected\""; echo ">".$val."</option>\n"; } Link to comment https://forums.phpfreaks.com/topic/214854-for-each-statements/#findComment-1117712 Share on other sites More sharing options...
Xtremer360 Posted September 30, 2010 Author Share Posted September 30, 2010 Thank you. Link to comment https://forums.phpfreaks.com/topic/214854-for-each-statements/#findComment-1117717 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.