Skip to content

Instantly share code, notes, and snippets.

@colindecarlo
Last active December 17, 2015 00:29
Show Gist options
  • Select an option

  • Save colindecarlo/5521017 to your computer and use it in GitHub Desktop.

Select an option

Save colindecarlo/5521017 to your computer and use it in GitHub Desktop.
<?php
$conn = mysql_connect("localhost", "twa312", "dam6av9a");
mysql_select_db("warehouse312", $conn)
or die ('Database not found ' . mysql_error() );
$sql = "select customerID, lastName from customer";
$rs = mysql_query($sql, $conn)
or die ('Problem with query' . mysql_error());
$options = '<option value="0">Choose</option>';
while ($row = mysql_fetch_array($rs)) {
$id = $row["customerID"];
$name = $row["lastName"];
$options .= '<option value="'. $id . '">' . $name .'</option>';
}
?>
<form method="GET" action="task8.php" id="custinfo" >
Choose name:
<select name="lname" id="lname">
<?php echo $options; ?>
</select>
<p><input type="submit" name="submit" value="Save Data"/>&nbsp;<input type="reset" value="Clear Form" />
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment