开发者

PHP Syntax problems

开发者 https://www.devze.com 2023-02-22 09:32 出处:网络
I am coding my first php application ever and I have a little problem. I´d like to have following output:

I am coding my first php application ever and I have a little problem. I´d like to have following output:

http://mysite.com/new_details.php?var1=abc&var2=cav&var3=bbc

Since I have to add class and styles and a javascript on click command open the url above, the echo has become a little complex:

echo "<tr" . ($index % 2 == 0 ? " class='grey'" : "") . " onclick=\"window.open('http://mysite.com/new_details.php?var1=". $result['0'] ."&var2=". $result['2'] ."&var3=". $result['3'] ."'); return false\">\n";

The output generated is:

<tr onclick="window.open('http://mysite.com/new_details.php?var1=abc&amp;var2=cca&amp;var3=awd'); return false">

Now this would be fine, excpet that t开发者_如何学Pythonhe "&" is being dispayed as "&amp;" and therefore doesnt work when its being used in the url.

Could anyone please point me in the right direction to fix this? thanks alot in advance :)


Add this at the end of your window.open command:

.replace('&amp;', '&')

The full line:

<tr onclick="window.open('http://mysite.com/new_details.php?var1=abc&amp;var2=cca&amp;var3=awd'.replace('&amp;', '&')); return false">
0

精彩评论

暂无评论...
验证码 换一张
取 消