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!
The file is being read as a javascript file through
<script language="JavaScript" src="js/calendar.php"></script>
and now I'm trying to assign a value of a variable $indiv to a variable that was declared in a function but for some reason I can't manage to get it to work
<?php
Header("content-type: application/x-javascript");
//Constructor
echo "function calendar(id,d,p){
this.id = id;";
$indiv; echo "= p; <----- I dont know how to make that call properly
...
...
What is $indiv? Is it supposed to hold a javascript variable name?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
$indiv is supposed to be called later on in the script in a php section that checks for the id of the object. And since I am using php logic to figure out some of this stuff I need a php variable to complete the logic.
I also read somewhere that this is impossible to do since php is server sided and javascript is client sided. So if this is the case is there a way to assign the variable within the php? If it is possible I was thinking that something to this extent would work:
You can render javascript from PHP but not can't render PHP from javascript, $indiv seems to be a PHP variable so you can use it to hold a javascript string. and then render it when required.
Hope that helps.
yeah that makes sense. Thank you. That was just the answer I didn't want to hear though. Since the only reason I need this variable is because it holds the id value that I want to use to search my database with and if I dont have a way to identify the search by anything it makes it a little hard to have the program work properly. So now I think I might just have to reprogram the whole thing in PHP so that I dont have to deal with this again. Well luckily it's already written in javascript