unemployment Posted January 21, 2011 Share Posted January 21, 2011 How do I echo the day from the db? It just displays day and I want it to display the day that was set. <select name="date_of_birth" id="date_of_birth"> <option value="">Day</option> <?php $isset = isset($_POST['date_of_birth']); for($day = 1; $day <= 31; ++$day) { echo '<option'; if ($isset && $_POST['date_of_birth'] === $day) { echo ' selected="selected"'; } echo ">${day}</option>\n\t\t\t\t\t\t"; } ?> </select> Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted January 21, 2011 Share Posted January 21, 2011 Wouldn't it be <select name="date_of_birth" id="date_of_birth"> <option value="">Day</option> <?php $isset = isset($_POST['date_of_birth']); for($day = 1; $day <= 31; ++$day) { echo '<option'; if ($isset && $_POST['date_of_birth'] === $day) { echo ' selected="selected"'; } echo ">{$day}</option>\n\t\t\t\t\t\t"; // Your dollar sign was outside the braces } ?> </select> Quote Link to comment Share on other sites More sharing options...
unemployment Posted January 21, 2011 Author Share Posted January 21, 2011 No, that isn't the issue. Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted January 21, 2011 Share Posted January 21, 2011 Well, now that I read the title a little closer I am even more confused. Echo the day from the db? You have no code for database access at all. Maybe I'm missing the point Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 21, 2011 Share Posted January 21, 2011 Agree with above re:no db reference; however, might try... <select name="date_of_birth" id="date_of_birth"> <option value="">Day</option> <?php $isset = isset($_POST['date_of_birth']); for($day = 1; $day <= 31; $day){ ?> <option value="<?PHP echo $day; ?>" <?PHP if ($isset && $_POST['date_of_birth'] === $day){ echo ' selected="selected"'; } echo ">" . $day . "</option>\n\t\t\t\t\t\t"; } ?> </select> 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.