I'm using php, and trying to build a code that allows me to search through my sql database vendors' passwords The search is based on vendor name . And it is possible that one vendor has more than one password . it is working fine , but one problem , which is when I try to select the vendor name , it is showing more than one time if in the database it shows more than one time . So how can I manage not to display the vendor name more than one time in the search options ? This is the php code I'm using:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<form action="/cloudpass/searchvendors.php" id="searchv" "method="GET"><br/><br/>
<select name="query" form="searchv">
<?php
$conn = new mysqli('localhost', 'root', '', 'mysql')
or die ('Cannot connect to db');
$sql = mysqli_query($conn, "SELECT vendor_name FROM vendors");
while ($row = $sql->fetch_assoc()){
$vendor_name = $row['vendor_name'];
echo '<option value="'.$vendor_name.'">'. $row['vendor_name'] .'</option>';
}
?>
</select>
<input type="submit" value="search" />
</form>
</body>
</html>