Ok I have devolped a code but it still displays all artists from a-z when you type in a letter and i want it to display only the artist names that start with the letter you type in here is my code how would i modify/change it to do what i want it to do:
<script src="
https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="
https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script>
//$(function() {
// $("#artistList").change(function () {
// var artistValue = $("#artistList option:selected" ).text();
// window.location.replace("/samphp/web/playlist.php?q="+artistValue);
// }
//});
function GoToArtist() {
artistValue = $("#artistList").val();
window.location.replace("/samphp/web/playlist.php?search="+artistValue);
}
</script>
<?php
$servername = "localhost";
$username = "alloldie_samdb";
$password = "Hockey26!";
$dbname = "alloldie_samdb";
echo "<select name='artist' id='artistList' onchange='GoToArtist()' style='padding: 5px;'><option>Artist Quick Search</option>";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT DISTINCT artist FROM songlist ORDER BY artist");
$stmt->execute();
// set the resulting array to associative
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach($stmt->fetchAll() as $k=>$v) {
//echo $v[] = $v;
echo "<option value='".implode($v)."'>".implode($v)."</option>";
//echo $data[] = $v;
}
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
echo "</option>";
?>