Reputation: 51
What is wrong in the following code?
<?php
echo "<td class='column1'><a href='#' OnClick='windowpopup(". secure_base_url()`"product/item/". $itemid ."/); return false;'>$row->title</a></td>";?>
?>
Why doesn't a popup window come up?
Upvotes: 0
Views: 1567
Reputation: 73282
Whats the value of $row->title
. Also, using single quotes will print the variable name, rather than its value.
edit: Ahh so there is more. Shamittomar, seems to have fixed your problem =)
Upvotes: 0
Reputation: 46692
After viewing hidden HTML, I must say here's how your code should look like:
<?php
echo "<td class='column1'><a href='#' OnClick='windowpopup(\"". secure_base_url() ."product/item/". $itemid ."/\"); return false;'>{$row->title}</a></td>";
?>
The reason is same though. You need to escape correctly and use double quotes for variables to expand in PHP.
Use this:
echo "{$row->title}";
Or
echo $row->title;
The PHP String Documentation says that:
"The most important feature of double-quoted strings is the fact that variable names will be expanded."
So, to expand variable names, either use double quotes and as precaution enclose them in {}
OR do not use quotes at all.
Upvotes: 5