Question:
How to add javascript in a fully PHP page?
Sparticus
2013-05-06 14:59:49 UTC
I have all ready seen several questions similar to this, but none of the answers work for me. I am using a .php file type and the entire body of the webpage is inside tags I use ECHO commands to post the HTML coding. I have tried to simply close the echo and php tags, insert the javascript then open a new php tag with echo commands for the rest of the page, but when I do that the layout of the page gets screwed up somehow. Most javascript works inside my PHP tags if I make sure to put "\" in front of single quotes. but this javascript uses "\" at several points in the code so I think it picks up my backslashes and thinks they are part of the code. so simply adding it inside the tags doesn't work either!
Three answers:
Sadsongs
2013-05-06 16:30:29 UTC
If you need a literal backslash in a restricted position, either in php or javascript, escape it with another backslash (ie double up).



Switching in and out of php on a single page shouldn't affect layout - there's either something wrong with what you're entering or something wrong with the CSS.
Robert
2013-05-06 15:04:56 UTC
There are two choices here, but with either of these two choices please do not think Javascript is any different to HTML as far as PHP goes.



The two choices are



1) Put parts outside of your Javascript

2) Within echo '

'; // works, as does

echo ''; // works, as does

echo '

'; // works
kiester
2016-10-04 13:29:55 UTC
nicely, the login two times and logout two times element is an illustration which you're no longer updating your consultation right previously you do the login/password examine. As for the skipping of Drew, this is considering you do a row fetch previously you get to the whilst loop, and then do yet another fetch for the subsequent row.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...