Page 1 of 1

Echo spacing.

Posted: Tue Mar 31, 2009 5:16 pm
by joe1986
Hi there,

I think its a bit of a simple one really but im a PHP newbie. Im trying to put a space in between the output values (shown below) and I thought the ." ". in the middle would solve this problem, but it turns out not; and im pulling my hair out. The code I have for output reads:

Code: Select all

while ($row = mysql_fetch_array($result)) {
   echo "  ".$row{'subject'}."  ".$row{'data'}."<br>";
and the output is displayed as:

"Subject Data"

I want to put more spaces in between these two values, e.g. "Subject _________ Data" (obviously without the _)

Could anybody please help me?

Cheers,

Joe

Re: Echo spacing.

Posted: Tue Mar 31, 2009 8:18 pm
by requinix
HTML will automatically collapse more than one space, tab, newline, all into one space. So " \n\t" (space, newline, tab) will be displayed as a " " in the HTML.

You should really be using CSS for this kind of thing, but until then use a "&nbsp;" instead of a space.

Code: Select all

echo "&nbsp;&nbsp;".$row{'subject'}."&nbsp;&nbsp;".$row{'data'}."<br>";