I have a value sitting in my database which i want to use in an external JavaScript file. The JavaScript file is being referenced in the the html code using <script src="/thanks/thanks.js"></script> 
Can anyone please help to figure out how i can either pass the value from php tp JavaScript or how i can access the database from the JavaScript?
            Asked
            
        
        
            Active
            
        
            Viewed 31 times
        
    -1
            
            
         
    
    
        Victor  
        
- 67
- 1
- 11
- 
                    can you at least try something (google may be your friend, or any other reference about php/javascript) ? Stackoverflow purpose is not to code something for you... – Pierre Feb 17 '18 at 09:02
1 Answers
0
            
            
        The simple way is to use the <script> tag and echo the value you want to.
<?php
    echo "<script>var parse = $value;</script>";
?>
Now you can use your value in javascript (parse variable). But if you want to have it detailed... here is the duplicate you didnt search for: How to pass variables and data from PHP to JavaScript?
 
    
    
        Felix Gaebler
        
- 702
- 4
- 23