I currently have some inline javascript in a php loop.

To make things simple, here is an example.

while($loop_data) {
echo $post_id;
alert("<?php echo $post_id ?>");
<? } ?>

Is there a way to stop the javascript from being the in the loop?
The reason is because im using a .load function and this stops the script from executing.