Running a php/sql query from javascript...is it possible?

Hey, so I have a form and I need it to do this:

When A select box is changed, it will run a query based on what it is changed too. Im not quite sure how to do it tho...as I have it right now:

<script type="text/javascript">

function ProjectUpdate(){

<?php

$ProjectID=$_POST['ProjectID'];


$queryProjects = "SELECT * FROM `pdem_projects`.`tblProjects` WHERE ProjectID = '$ProjectID'";
$resultProjects = mysql_query($queryProjects);

$projArray = mysql_fetch_assoc($resultProjects);

?>

document.form1.ProjectName.value = "<?php echo $projArray['ProjectName'];?>"
document.form1.Client.value = "<?php echo $projArray['Client'];?>"

}

</script>

Hopefully that will give you an idea of what I am trying to do..I think it is fairly straight forward...Its just, when the javascript function runs, it just skips right over the php code.

Hope there is a solution
thanks
 
Back
Top