Onclick & attributes within <td within echo - syntax problems at least

I have a PHP script that writes a calendar and writes each day with an echo. there are individual events assigned to each day. clicking on the date field opens a window to add an event. clicking on existing event within each day opens a window showing details of that event. the following should give you the idea:

// write start of box
echo “<td width=\“100\” height=\“100\” class=\”$class\"; >

// this bit writes the date in corner of the current box, it is a link to event_add.php script
$link_month = $_GET[‘month’] - 1;
echo "<div align=\“right\”>
<span class=\“toprightnumber\”>\

	&lt;a href=\\"javascript:MM_openBrWindow('/calendar/event_add.php?day=$i&amp;month=$link_month&amp;year=$_GET[year]','',


…echo this, echo that, echo the other thing…

// write end of box
echo "</td>

now I’m trying to rearrange things. I want the entire cell to be the clickable link. click it and up pops a window showing all events assigned to that day, and then we will view, add, or delete events from there.

I think I need a “onclick” within my <td, but can’t get the syntax to work. can’t find any working examples anywhere, which worries me that my whole approach is wrong.

any help at all with this is GREATLY APPRECIATED.

The following should work:

echo "<td width=\\"100\\" height=\\"100\\" class=\\"$class\\" onclick=\\"MM_openBrWindow('/calendar/event_add.php?day=$i&amp;month=$link_month&amp;year=$_GET['year']','',

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\calendar\index.php on line 140

Oops sorry about that. Try this:

echo "<td width=\\"100\\" height=\\"100\\" class=\\"$class\\" onclick=\\"MM_openBrWindow('/calendar/event_add.php?day=$i&amp;month=$link_month&amp;year={$_GET['year']}','',

SWEET!! works like a charm! thanks a million Jaanboy!

If you want to avoid all the backslash-escaping, try HEREDOC/NOWDOCs:

echo <<<"EOD"
<td width="100" height="100" class="{$class}" onclick="MM_openBrWindow('/calendar/event_add.php?day={$i}&amp;month={$link_month}&amp;year={$_GET['year']}','','width=500,height=500');">

thanks Alien, that does look better. will try soon.

Parse error: syntax error, unexpected T_SL in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\calendar\index.php on line 145

Remove the quotes from <<<“EOD”.


you know your $#!+ Jaanboy… thanks again!

For future reference, it also helps to ensure that the end EOD; is flush left, with no spaces or other text to the right of the semicolon.

thanks 57, yea… I discovered that the hard way! I like to indent things.