好的。我正在为我的互联网电台做一个节目日程管理器。我已经走到这一步了,但似乎想不出在编辑时如何处理节目的播出时间和结束时间。下面是表单中的代码。
时间以24小时格式存储在HTML数据库中,以便于排序。
如果您需要查看其余代码:https://github.com/phillf/ProgramScheduleManager
代码来自: admin/editShow.php:
<td>What time does this show start?</td>
<td>
<select name="AirTime">
<?php for($i = 0; $i < 24; $i++): ?>
<option value="<?= $i; ?>"><?= $i % 12 ? $i % 12 : 12 ?>:00 <?= $i >= 12 ? 'pm' : 'am' ?></option>
<?php endfor ?>
</select>
</td>
<tr>
<tr>
<td>What time does the show end?</td>
<td>
<select name="EndTime">
<?php for($i = 0; $i < 24; $i++): ?>
<option value="<?= $i; ?>"><?= $i % 12 ? $i % 12 : 12 ?>:00 <?= $i >= 12 ? 'pm' : 'am' ?></option>
<?php endfor ?>
</select>
</td>
</tr>发布于 2013-05-20 23:00:53
假设您已经执行了一个数据库查询,并将当前的广播时间放在$airTime中,您可以像这样设置selected属性:
<select name="AirTime">
<?php for($i = 0; $i < 24; $i++): ?>
<option value="<?= $i; ?>:00:00" <?php if ($i == $airTime) { echo 'selected'; } ?> ><?= $i % 12 ? $i % 12 : 12 ?>:00 <?= $i >= 12 ? 'pm' : 'am' ?></option>
<?php endfor ?>
</select>对于EndTime也是如此。
https://stackoverflow.com/questions/16652094
复制相似问题