- This topic is empty.
-
AuthorPosts
-
January 16, 2013 at 7:07 am #42027
ajnoguerra
ParticipantONMOUSEdown=”document.images.src=’images/linkedin.png'”>
ONMOUSEdown=”document.images.src=’images/facebook.png'”>
How do I write this code inside PHP echo ” “;
echo “
“
?>I tried writing it just like the above code but it doesn’t work.
January 16, 2013 at 7:30 am #121152Andy Howells
ParticipantNeed to add a ; to the end of your echo after the closing quote mark.
January 16, 2013 at 10:24 am #121163__
Participantjust so you know, this:
echo “
<.img src='images/linkedin-icon.png' onMouseDown='document.images['large'].src='images/linkedin.png' ' />
<.img src='images/facebook-icon.png' onMouseDown='document.images['large'].src='images/facebook.png' ' />
<.img src=' ' name='large'>” ;
and this:
?>
<.img src='images/linkedin-icon.png' onMouseDown='document.images['large'].src='images/linkedin.png' ' />
<.img src='images/facebook-icon.png' onMouseDown='document.images['large'].src='images/facebook.png' ' />
<.img src=' ' name='large'>are *exactly* equivalent.
Also, when writing HTML (or anything else that may have quote marks), it’s usually much easier to use the HEREDOC notation:
$string = <<< HTML
Hello, I’m using “quotes” left and right, and I don’t need to escape them.
I can still use $variables in my text,
or even {$nested}.
A “HEREDOC” is like a “double-quote” string,
but it starts with three less-than brackets ( <<< )
followed by a token (anything; I used “HTML” here)
and ends when the token appears at the beginning of a line
(by itself, no indentation at all),
with a semicolon by itself on the next line.
Have a try!
HTML
;January 16, 2013 at 11:07 am #121167Rai
MemberTry this:
your html here
your html here
your html here
January 16, 2013 at 6:13 pm #121204ajnoguerra
ParticipantThank you for all your answers ( @Rai, @traq, @AndyHowells ). One problem that I keep on encountering with that code is the pure html works and does swap image but when I try to incorporate it inside PHP, it doesn’t work anymore. That is why i’m looking for a work around on how to write it inside PHP because I will be getting the image source from a database if only those code will work. :( Please help…
January 16, 2013 at 7:34 pm #121209__
ParticipantWell, what do you mean by “doesn’t work”?
What actually happens vs. what you expected?
Did you make sure error reporting is enabled, and do you get any error messages?
January 16, 2013 at 8:40 pm #121217ajnoguerra
Participant@traq, Sorry if I sound a little confusing. The pure HTML markup with a little javascript I posted does a “swap image”. The small/thumbnail images when clicked , a bigger version of that image will appear below. But then when I try to rewrite the code inside PHP and run it in a browser, it doesn’t do anything when you click the thumbnail image but I didn’t get any error messages.
January 16, 2013 at 8:46 pm #121218__
Participant@ajnoguerra what does the output HTML look like?
January 16, 2013 at 9:25 pm #121222ajnoguerra
Participant@traq, I’m glad you’re really trying to help me. Here’s the output >>> [swap image](http://codepen.io/ajnoguerra/pen/kdsnD “simple-swap-image”)
January 16, 2013 at 11:52 pm #121231__
Participant> Here’s the output
That seems to work as expected, unless I misunderstand your problem.
Are you sure you posted the **output** HTML (i.e., the HTML *that is generated by PHP* and demonstrates your problem)?
January 17, 2013 at 9:33 pm #121314ajnoguerra
Participantmysql_connect(“localhost”,”root”,””) or die (mysql_error());
mysql_select_db(“motoactiv-db”) or die (mysql_error());$sql = “Select * FROM products”;
$result = mysql_query($sql);
while($record=mysql_fetch_array($result))
{
?>}
?>I still haven’t figured out the problem with this because when I tested it out in Firefox and IE it works just fine but when I tried it with Chrome, it doesn’t make the bigger image come out, it is as if no javascript was implemented. @traq
January 18, 2013 at 1:28 am #121335__
Participant@ajnoguerra – see my comment in your other thread.
January 18, 2013 at 4:19 am #121339noahgelman
Participant>
Why are you escaping the quotes? You don’t need to do that. You only need to do that when the quotes are the same as the surrounding quotes. If your html is inside double quotes, you don’t need to escape single quotes.
January 18, 2013 at 4:24 am #121341natashakimly
Memberwow such a great info. [http://adiphene.webs.com](http://adiphene.webs.com “http://adiphene.webs.com”)
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.