tags:

views:

84

answers:

4
$html=<<<html
<tr><td>$i.<a href="offtask.php?taskid=$taskid target='_blank' ">$title</a></td><td>$count</td><td class="nowrap">$locationtext</td></tr>
html;
echo $html;

How to open a new window in the code above? target='_blank' doesn't work.

+3  A: 

look at the code output by that code. It will look like this:

<tr><td>$i.<a href="offtask.php?taskid=$taskid target='_blank' ">$title</a></td><td>$count</td><td class="nowrap">$locationtext</td></tr>

and you want it to be

<tr><td>$i.<a href="offtask.php?taskid=$taskid" target="_blank">$title</a></td><td>$count</td><td class="nowrap">$locationtext</td></tr>

That is:

<a href="url" target="_blank">link</a>
Marius
+6  A: 

Your target attribute is stuck inside your href attribute. Try this:

$html=<<<html
<tr><td>$i.<a href="offtask.php?taskid=$taskid" target="_blank">$title</a></td><td>$count</td><td class="nowrap">$locationtext</td></tr>
html;
echo $html;
Asaph
Thank you,@Asaph
Steven
+1  A: 

The reason it's not working is because you haven't separated your link attributes properly. Try outputting the href and the target with proper separation (ie, close your quotes).

Use this:

<a href="offtask.php?taskid=$taskid" target='_blank'>

instead of

<a href="offtask.php?taskid=$taskid target='_blank' ">
zombat
+1  A: 
<a href="offtask.php?taskid=$taskid" target="_blank">
GrayWizardx