I have created a javascript function. And the work of that function is to store the value which is selected by the user. Now I want to do that if the user selects the value then that value should be searched inside the database.
<script>
function test(){
var a=$("#to_artist").val();
var aakash="<option>Select If you want to change</option><?php
define('DB_HOST','localhost');
define('DB_USERNAME','username');
define('DB_PASSWORD','password');
define('DB_NAME','dbname');
//echo '<script> $("#to_artist").val(); </script>';
$con = mysqli_connect(DB_HOST,DB_USERNAME,DB_PASSWORD,DB_NAME) or die("Unable to connect");
$sql = mysqli_query($con, "SELECT * FROM album;");
$row2 = mysqli_num_rows($sql2); ?>";
aakash+="<?php while ($row2 = mysqli_fetch_array($sql)){echo "<option value='". $row2['album_name'] ."'>" .$row2['album_name'] ."</option>" ;} ?>" ;
$("#to_album").append(aakash);
}
</script>
I want to use Select * from album where artist=a
this query inside PHP but i don't know how i can use this can any one help me.