Hi guyz...
I need some with my php code.
I want to have a pop window in my a href link inside the php code.
But I have problems coz there is an error regarding with my script inside the php
Here is my code
echo "<td><img src=".$img[$x]." width='250' height='250'><br>".'<input type="checkbox" name="formVotes[]" value="'.$canId[$x].'" /><br>'.$fName[$x]." ".$mName[$x]." ".$lName[$x]." ".'</input><br> <a href="viewprofile.php?canid='.$canId[$x].'" target="popupWin" onsubmit="return openWindow('addProfile.php', 'popupWin', 1000, 500);">View Profile</a></td>';
I really need your help guyz...
Thank you in advance!
Javascript inside PHP code
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Javascript inside PHP code
What type of error are you receiving? A quick look at your code shows that you aren't escaping the quotation marks correctly.
If you are encassing your statements in double quote marks (") any double quotes inside the statement has to be escape, like in example 1. Same goes for single quotation marks (per example 3). I find that it's easier to use single quotes to encase when working with html where " is required i.e src="path/to/file".
Code: Select all
<?php
// example 1
echo "<img src=\"path/to/file\" width=\"100\" height=\"100\" />";
// example 2
echo '<img src="path/to/file" width="100" height="100" />';
// example 3
echo 'Hello \'World\' ';
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering