How to write the php code in js file

annoupietatom

New Member
Is my program i divide the pages as a div in the first div i added this code\[code\] <?php $table="am_users"; $query="select distinct(`user_email`) from $table"; $result=mysql_query($query); $num_rows = mysql_num_rows($result); while($data1=mysql_fetch_array($result)) { $data[]=$data1['user_email']; } sort($data); foreach($data as $search_term) { $js_data[] ="\"" . $search_term . "\""; } <script type="text/javascript">var collection = [<?php echo implode($js_data, ","); ?>]; </script> ?> \[/code\]below this i include my css filebut division 1 is working in division 2 the css is not applied . This Problem is due to the div 1 had Js variable value If I remove the var collection = []; statement then the css working fine . So Is It possible to pass the value from PHP file to JS file On Loading Time
 
Back
Top