I Tried lot but can't solve this problem
Here is my Code:
<?php
while($crow = mysqli_fetch_assoc($cres)) {
echo '
<div class="item" onclick="window.open("'.$crow["c_link"].'");window.open("'.$crow["c_link"].'","_self")<img src="images/carousel/'.$crow["c_pic"].'" alt="'.$crow['c_nm'].'"></div>
';
}
?>
There is error Like this:
I also tried another answer of this problem but it is not working for me. can anybody please tell me how to solve this ?
Problem is with mixed quotes and aprostrophes
onclick="window.open("
You open onclick
attribute value with "
character and then close the attribute just after window.open(
. Instead of the second "
use \\'
or IMO even better close PHP mode, print HTML code and open PHP mode only to print PHP values
while($crow = mysqli_fetch_assoc($cres)) {
?><div class="item" onclick="window.open('<?=$crow['c_link']?>'); window.open('<?=$crow['c_link']?>');"><img ... ></div><?php
}
?>
this way it's easier to not get confused by combination of JS and PHP quotes and apostrophes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.