Page 1 of 1

how to use php code in javascript tag

Posted: Mon Sep 27, 2004 4:44 am
by bugthefixer
can i use php code in javascript tag
like

<script>
<?php
?>
</script>

wat cud be the best way to do tat as i want display data fetched from database by php n displayed by javascript code..javascript code is too much so that i cant write the whole code in echo.

Posted: Mon Sep 27, 2004 4:55 am
by kettle_drum
Yep, you do what you have done.

Remember that php is server-side and just returns text to the client, so if you just want to add a few pre-defined strings to your javascript then its fine.