PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Rangana
Forum Newbie
Posts: 6 Joined: Thu Sep 04, 2008 4:36 am
Post
by Rangana » Fri Sep 12, 2008 5:02 am
I want to add that code in within php code. but that is not work but without php code that is work how am i implement that PLS help me
That code is work
Code: Select all
<table border="2">
<tr>
<td> <p align="left"><a href="javascript:showbox('Div1');">Show box 1 again</a></td>
<td>"eeeee"</td>
</tr>
</table>
I wnt to do in this way but it's not work
Code: Select all
<?php
print '<table border="2">';
print '<tr>';
print '<td> <p align="left"><a href="javascript:showbox('Div1');">Show box 1 again</a></td>';
print '<td>"eeeee"</td>';
print '</tr>';
print '</table>';
?>
jayshields
DevNet Resident
Posts: 1912 Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England
Post
by jayshields » Fri Sep 12, 2008 6:55 am
If you're going to use single quotes inside single quotes (or double quotes inside double quotes) then you need to escape the inner quotes with a backslash. For some reason the PHP tag parser on here won't let me give you an example...
BETA
Forum Commoner
Posts: 47 Joined: Fri Jul 25, 2008 3:21 am
Post
by BETA » Fri Sep 12, 2008 7:28 am
I use to do it this way
Code: Select all
<?php
echo '
<table border="2">
<tr>
<td> <p align="left"><a href="javascript:showbox('Div1');">Show box 1 again</a></td>
<td>"eeeee"</td>
</tr>
</table>';
?>
dunno really if thats the good way but it works for me...
marcth
Forum Contributor
Posts: 142 Joined: Mon Aug 25, 2008 8:16 am
Post
by marcth » Fri Sep 12, 2008 7:37 am
BETA wrote: I use to do it this way
Code: Select all
<?php
echo '
<table border="2">
<tr>
<td> <p align="left"><a href="javascript:showbox('Div1');">Show box 1 again</a></td>
<td>"eeeee"</td>
</tr>
</table>';
?>
dunno really if thats the good way but it works for me...
You don't need PHP here, so why use it?
Code: Select all
<?php
// Some PHP code
?>
<table>
<tr>
<td><a href="javascript:showbox('Div1'); return false;">Show box 1 again</a></td>
<td>eeeee</td>
</tr>
</table>
<?php
// Back to PHP
?>
BETA
Forum Commoner
Posts: 47 Joined: Fri Jul 25, 2008 3:21 am
Post
by BETA » Fri Sep 12, 2008 7:41 am
lol true i do i that way too...
just thought he couldn't use that for some reason... like when u need to insert content dynamically
marcth
Forum Contributor
Posts: 142 Joined: Mon Aug 25, 2008 8:16 am
Post
by marcth » Fri Sep 12, 2008 7:48 am
BETA wrote: lol true i do i that way too...
just thought he couldn't use that for some reason... like when u need to insert content dynamically
It is extremely important to separate your PHP from your presentation--I don't even put them in the same file.
Code: Select all
<?php
$boxes = array(
1 => 'Box 1',
2 => 'Box 2',
3 => 'Box 3',
);
?>
Code: Select all
<table>
<?php foreach($boxes as $id=>$value) { ?>
<tr>
<td><a href="javascript:showbox('Div<?= $id ?>'); return false;">Show <?= $value ?> again</a></td>
<td>eeeee</td>
</tr>
</php } ?>
</table>
Edit: Some people feel strongly that using <?= ?> instead of <?php echo '' ?> is bad.