The way you have that written the php is actually inside of a javascript. So both the javascript and the php will throw fatal exceptions.

if you are trying to get a value from the client to the server for use in a query, then the client has to send the value across as a query string value on an url or as an input value on a submitted form.

PHP runs on the server
JavaScript runs on the client (in the browser)
When someone requests your page any PHP is processed and executed before it gets sent back to the browser. It doesn't exist anymore at that point.

If you want to do some dynamic data manipulation then you need to look at Ajax.
Using ajax depending on what the user does in the browser you can request new data from the server and update the webpage.

Isn't the function called when you click on the plus sign to open it? So the php data would run after that.

No. The javascript function is run, but the PHP has already been parsed by then. Look at this:

<script>
alert("<?php echo "Hello" ?>");
</script>

When you request the page, the PHP is parsed on the server, so by the time your page hits your screen, what you'll actually see in your browser's source is just:

<script>
alert("Hello");
</script>

There will be no sign of PHP because that's handled at the server. By the time you view the page, you're on the client-side.

As Gary said, if you want your page to dynamically run PHP code, you will have to create an AJAX request. This will then allow the client-side code (javascript) to request new data from the server-side (PHP), but the 2 never directly interact (one makes a request / the other responds)

In markup, there are three different "counts" of markup elements: zero, one and many. Obviously zero elements do not need markup.

If there is one element (unique) it is identified by the id= attribute. It is tagged with the # character.

If there are multiple elements (or potentially multiple elements) they are identified with the class= attribute. They are tagged with the . (period) character.

If you have more than one element with an identical id= attribute, you have invalid markup and you need to redesign the document. You can use the W3 validator to check for errors like that.http://validator.w3.org/

0

Featured Post

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

There are times when I have encountered the need to decompress a response from a PHP request.
This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.

Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…