<script>
var test = 1;
<?php
$id = "document.write(test)" ;
//echo $id;
//here i want to run sql code
?>
var id =<?php echo $id; ?>;
alert(id);
</script>
fist i want pass test value to php id second i wanna pass php id value to var id . when i run this code alert says Undefined . How to display id in a alert.