how to use php code in javascript tag

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bugthefixer
Forum Contributor
Posts: 118
Joined: Mon Mar 22, 2004 2:35 am

how to use php code in javascript tag

Post 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.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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.
Post Reply