javascript - How to write the php code in js file -
is program divide pages div in first div added code
  <?php     $table="am_users";     $query="select distinct(`user_email`) $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 $search_term)       {       $js_data[] ="\"" . $search_term . "\"";        }   <script type="text/javascript"> var collection = [<?php echo implode($js_data, ","); ?>];  </script>         ?>  below include css file division 1 working in division 2 css not applied . problem due div 1 had js variable value if remove var collection = []; statement css working fine . possible pass value php file js file on loading time
save file .php instead of .js , add
header("content-type: application/javascript"); . @ beginning of file. after able link file
<script type="text/javascript" src="youfile.php"></script> 
Comments
Post a Comment