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&var2=cca&var3=awd'); return false">
Now this would be fine, excpet that t开发者_如何学Pythonhe "&
" is being dispayed as "&
" 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('&', '&')
The full line:
<tr onclick="window.open('http://mysite.com/new_details.php?var1=abc&var2=cca&var3=awd'.replace('&', '&')); return false">
精彩评论