Today at 1:47pm, Merrill Oveson said:

> List:
>
> I don't mean to get greedy, but...
>
> using this method, would it be possible to get data from a database
> into javascript?
>
> for example, I create a php script with a function (say the function
> name is Query) that queries the database and returns a value.
> then in javascript I say:
>
> var this = "<?php $value = Query(); echo $value; ?>";
>
> this should work, shouldn't it?

Yes, that can work, so long as the file in question is getting parsed by 
PHP. I've done some stuff with dynamically generated CSS files like that 
before, it should work with JS too.

Mac

> Thanks again
>
> Merrill
>
> On Wed, Jan 19, 2011 at 11:27 AM, Wade Preston Shearer
> <[email protected]> wrote:
>> On 19 Jan 2011, at 11:21, Merrill Oveson wrote:
>>
>>> I have an app_constants.php file in the includes directory.
>>>
>>> I have another php files that reads the constants from this file.
>>> This other php file also have javascript in it.
>>>
>>> Is it possible to have the javascript read the constant variables in
>>> the app_constants.php file?
>>
>> If you javascript (or at least part of it) is written out by PHP then yes, 
>> you can write out:
>>
>> var this = "<?php echo CONTSTANT: ?>";
>>
>>
>
> _______________________________________________
>
> UPHPU mailing list
> [email protected]
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net
>

--
Mac Newbold                     Code Greene, LLC
CTO/Chief Technical Officer     268 S State St #100
Office: 801-582-0148 x102       Salt Lake City, UT  84111
Cell:   801-694-6334            www.codegreene.com

_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to