title: Mysql info in select tag
body: <p>So I've been trying to figure out how to do this but I've had no luck. </p>
  
  <p>I have a database that includes ID, name, date, and username </p>
  
  <p>I have a simple submit form that generates an id and a user adds a name and an event date then it logs the username, However I would like to take that date and then have it appear in a select tag with the format of Name - Date and have it sorted by the closest date. I want to view info about that event when someone clicks it. But I can't figure out how to make it appear in the select tag. I don't even know where to start with this. all help appreciated.</p>
  
  <pre><code>$conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  } 
  
  $id = uniqid(rand(), false);
  $name=$_POST['name'];
  $date=$_POST['date'];
  $username = $_POST['username'];
  
  
  // Insert data into database
  
  $sql="INSERT INTO events (id, name, date, username)
  VALUES
  ('$id', '$name', '$date', '$username')";
  
  if ($conn-&gt;query($sql) === TRUE) {
      echo "";
  } else {
      echo "Error: " . $sql . "&lt;br&gt;" . $conn-&gt;error;
  }
  
  error_log(implode("-",$_POST));
  
  
  
  $conn-&gt;close();
  ?&gt;
  </code></pre>