How i can take JavaScript value inside php : <p>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.</p>

<pre><code>&lt;script&gt;
function test(){

   var a=$("#to_artist").val();
    var aakash="&lt;option&gt;Select If you want to change&lt;/option&gt;&lt;?php
define('DB_HOST','localhost');
define('DB_USERNAME','username');
define('DB_PASSWORD','password');
define('DB_NAME','dbname');

//echo '&lt;script&gt; $("#to_artist").val(); &lt;/script&gt;';
$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); ?&gt;";
    aakash+="&lt;?php while ($row2 = mysqli_fetch_array($sql)){echo "&lt;option value='". $row2['album_name'] ."'&gt;" .$row2['album_name'] ."&lt;/option&gt;" ;} ?&gt;" ;
   $("#to_album").append(aakash);
}
&lt;/script&gt;
</code></pre>

<p>I want to use <code>Select * from album where artist=a</code>  this query inside PHP but i don't know how i can use this can any one help me.</p>
