phpbigenner Posted August 15, 2013 Share Posted August 15, 2013 i have a problem on how to trap the time to enable the checkbox, can you help? example. the db name is time_schedule then the fields are 'time_start' and 'time_end' then there's a checkbox inside the html. my problem is how to enable the checkbox if the time schedule is not equal to the 'time_start' and 'time_end' value. need help guy's Link to comment https://forums.phpfreaks.com/topic/281222-how-to-enable-checkbox/ Share on other sites More sharing options...
Psycho Posted August 15, 2013 Share Posted August 15, 2013 You need to supply some sample data or something. What field types are time_start and time_end: time, datetime, timestamp, ??? And, what is the value of the "time schedule"? Does it have a start and end time? But, you probably have two choices: 1. Do all the logic in PHP. Select your records from the database and then compare the fields when processing each record to determine if the checkbox should be enabled or not. 2. Use the comparison in the query to dynamically return a Boolean value on whether the checkbox should be enabled or not. In either case the final code could likely look something like this: while($row = mysql_fetch_assoc($result)) { $disabled = (CONDITION) ? ' disabled="disabled"' : ''; echo "<input type="checkbox" name=\"{$row['field_name']}\" {$disabled} value=\"{$row['valule']}\" /> {$row['label']}"; } CONDITION will either be the logic that you do in PHP or the dynamic value you calculated in the query Link to comment https://forums.phpfreaks.com/topic/281222-how-to-enable-checkbox/#findComment-1445250 Share on other sites More sharing options...
phpbigenner Posted August 15, 2013 Author Share Posted August 15, 2013 time_start and time_end are strings. then the value of time schedule have time_start and time_end. Link to comment https://forums.phpfreaks.com/topic/281222-how-to-enable-checkbox/#findComment-1445251 Share on other sites More sharing options...
Psycho Posted August 15, 2013 Share Posted August 15, 2013 Um, ok, you still haven't provided examples of what the data looks like. How can I provide an example of how you would compare those values when I don't know what format they are in? Also, if you are storing the values in the database as text and not as appropriate field types for a "time" element, then you are doing it wrong. Link to comment https://forums.phpfreaks.com/topic/281222-how-to-enable-checkbox/#findComment-1445254 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.