how to insert hour and minute in the mysql database… the hour and minute each one having a dropdown list while we select a time and minute it will store to database…how it will be done pl tell me any suggestion…i have used varchar datatype…i need HH:MM format only no need to display seconds…pl clarify my doubt as soon as possible

Here’s a quick demo to get you going. :wink:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <form action="" method="post">
      <select name="hour">
        <?php foreach(range(0, 23) as $hour): ?>
          <?php printf('<option value="&#37;1$02d">%1$02d</option>', $hour); ?>
        <?php endforeach; ?>
      <select name="minute">
        <?php foreach(range(5, 55, 5) as $minute): ?>
          <?php printf('<option value="%1$02d">%1$02d</option>', $minute); ?>
        <?php endforeach; ?>
      <input type="submit" value="Submit" />
    <?php if('POST' === $_SERVER['REQUEST_METHOD']): ?>
      <?php printf("<pre>SQL: INSERT INTO table (selected_time) VALUES ('%02d:%02d');</pre>", $_POST['hour'], $_POST['minute']); ?>
    <?php endif; ?>

Use the TIME datatype, not VARCHAR. :wink: