mfaulkner Posted February 2, 2007 Share Posted February 2, 2007 Hi all, This problem has had be going round in circles now for a couple of weeks, if somebody could provide a solution I would be really really grateful. First off, what I want to do... Have an HTML drop down menu that can set a status of a day to 'Available' or 'Booked'. Inserting the initial data isn't important, so its only function is as an update form/query. Its a really simple MySQL database, with only 1 table and 2 fields. (The day field is the primary key). So, when the page is loaded, the default option should be selected in the drop down menu, then it can be modified if necessary. As its an update form its imperative that the stored value in the ENUM (Available or Booked) is selected as the default. Once I have it working for 1 day, I should be able to modify it for a complete month, then year. Thanks in advance guys. Mark. Here's what I've attempted (unsuccessfully) so far plus a couple of screenshots to make clear the database structure. <?php $jan = "SELECT jan_day, jan_status FROM january WHERE jan_day = 1"; $result = mysql_query($jan) or die ("Error in query: $query. " . mysql_error()); while (list($jan_day, $jan_status) = mysql_fetch_row($result)) { ?> <form> <select name="jan_1" size="1"> <option value="1" <?php if ($result['jan_status'] == "1") { echo "selected"; } ?>>Available</option> <option value="2" <?php if ($result['jan_status'] == "2") { echo "selected"; } ?>>Booked</option> <?php } ?> </select> </form> Quote Link to comment https://forums.phpfreaks.com/topic/36728-retrieve-value-stored-in-enum-for-default-option-in-drop-down-menu/ Share on other sites More sharing options...
AndyB Posted February 2, 2007 Share Posted February 2, 2007 What am I missing? If jan_status can have two values - available and booked - why are you using 1 and 2 as the options in a select dropdown for jan_status. Surely, your dropdown values need to be available and booked, not 1 and 2? Quote Link to comment https://forums.phpfreaks.com/topic/36728-retrieve-value-stored-in-enum-for-default-option-in-drop-down-menu/#findComment-175279 Share on other sites More sharing options...
HuggieBear Posted February 2, 2007 Share Posted February 2, 2007 What am I missing? If jan_status can have two values - available and booked - why are you using 1 and 2 as the options in a select dropdown for jan_status. Surely, your dropdown values need to be available and booked, not 1 and 2? Having just read the post three times, I totally agree. Mfaulkner, I think your logic has gone awry somewhere along the line. Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/36728-retrieve-value-stored-in-enum-for-default-option-in-drop-down-menu/#findComment-175300 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.