Just want to echo a lousy space, c'mon!

just when I thought I was getting the hang of things I find I cannot even echo a lousy space here:


while (list($key, $value) = each ($events[$i])) 
				{
if ($event_info[$value]['2'] == "Agreed") {echo "<div style=\\"color: green;\\">" . " " . $event_info[$value]['0'] . "</div>\
";}	
			}

tried &nbsp too. this should be to simple to fail! can someone please enlighten me.

thank you!

I can’t attest to the correctness of your loop or conditional, but if they both run, you do have a space at the start of that div. Though there’s no reason to separately concatenate said space instead of just putting it on the end of the literal string right before it.

That said, your code’s very strange. You create this loop but don’t use $key, $value or $events anywhere in it. If you just want to loop as many times as the size of $events[$i], then create a for loop with count($events[$i]) as the limit.

thanks Dan. yea, I’m learning am will look at my poor code after I resolve this space thing. it runs, but the space is not there. any idea why? will try line before you suggested. thank you!

If you see that div, then the space is there. View the source HTML of your webpage. Maybe it’s just not easy to see, visually, given the layout of your site.

I’m not seeing it.
here is code that works, it writes a space before $events[i] - it’s my “model”:

IF(isset($events[$i]))
		{
		
			echo "&lt;div align=\\"left\\"&gt;&lt;span class=\\"eventinbox\\"&gt;\

";
while (list($key, $value) = each ($events[$i]))
{

			 echo "&nbsp;&lt;a href=\\"javascript:MM_openBrWindow('/calendar/event.php?id=$value','','width=500,height=500');\\"&gt;"				  
 		
			 . " " . $event_info[$value]['0']  . "&lt;/a&gt;\

<br>
";
}

			echo "&lt;/span&gt;&lt;/div&gt;\

";
}

and here’s some that does not write a space before the $event[i]:

IF(isset($events[$i]))
{
echo "<div align=\“left\”><span class=\“eventinbox\”>
";

			while (list($key, $value) = each ($events[$i])) 
			{

				if ($event_info[$value]['2'] == "Declined"){					
					echo "&nbsp; &lt;div style=\\"color: red;\\"&gt;" . " " . $event_info[$value]['0'] . "&lt;/div&gt;\

<br>
“;}
if ($event_info[$value][‘2’] == “Pending”){
echo "  <div style=\“color: #FF3300;\”>” . " " . $event_info[$value][‘0’] . "</div>
<br>
“;}
if ($event_info[$value][‘2’] == “Agreed”){
echo "  <div style=\“color: green;\”>” . " " . $event_info[$value][‘0’] . "</div>
<br>
";}
}

			echo "&lt;/span&gt;&lt;/div&gt;\

";
}

so what’s the difference? an echo is an echo, is an echo, right?

thanks again!

How about pasting the HTML code this generated.

Not to call you a liar, but well, I’m calling you a liar – I don’t believe you. Don’t take that personally. I feel it’s more likely a human is mistaken than that an echo statement is deciding to alter its arguments and deleting the space.

“I don’t see it” doesn’t mean “it’s not there”, especially since you did not give context to the “I don’t see it” part – see it when viewing the webpage, or viewing the HTML?

ERRR… you’re right! I should have thought of checking here.

<td width=“100” height=“100” class=“dayboxes” ondblclick=“javascript:MM_openBrWindow(‘/calendar/run_this_day.php?day=16&month=2&year=2010’,‘’,‘width=500,height=700’);”><div align=“right”>16
<div align=“left”><span class=“eventinbox”>
  <div style=“color: red;”> no title</div>

<br>
  <div style=“color: green;”> accept-decli</div>
<br>
  <div style=“color: red;”> acpt-dcl tes</div>
<br>
</span></div>
</td>
<td width=“100” height=“100” class=“dayboxes” ondblclick=“javascript:MM_openBrWindow(‘/calendar/run_this_day.php?day=17&month=2&year=2010’,‘’,‘width=500,height=700’);”><div align=“right”>17
<div align=“left”><span class=“eventinbox”>
  <div style=“color: #FF3300;”> color test</div>

<br>
  <div style=“color: #FF3300;”> GET UP!</div>
<br>
</span></div>
</td>

so now the problem must be somewhere up here, yes? —

// this bit writes the date in corner of the current box
echo "<div align=\“right\”>$i
";

	IF(isset($events[$i]))
		{
			echo "&lt;div align=\\"left\\"&gt;&lt;span class=\\"eventinbox\\"&gt;\

";
// this WHILE bit writes all the events assigned to the current box
while (list($key, $value) = each ($events[$i]))
{

but it hasn’t changed…

Your HTML has the spaces you wanted, so what do you now consider the “problem”?

well they don’t seem to be present when viewing the site. I need to look for something else I changed outside of these echos. the solution must be there. thank you for your help Dan.

You shouldn’t put <div>'s, a block level element, inside <span>'s, an inline level element

THAT’S the difference, huh! hope it’s a fix. thanks again Dan!