How to align my data???

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

Post Reply
slipstream
Forum Commoner
Posts: 86
Joined: Fri Apr 19, 2002 8:53 am
Location: Canada

How to align my data???

Post by slipstream »

I output it like this:

echo $info[0].' &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp ';
echo $info[1].' &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp ';
echo $info[2].' &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp ';

but instead of &nbsp I want to start my next output at column 30 or whatever, using &nbsp doesn't align it and it looks ugly..
User avatar
forgun
Forum Commoner
Posts: 61
Joined: Wed Jan 29, 2003 6:05 am
Contact:

Post by forgun »

why u dont try to use the tags html

Code: Select all

<div align="center"></div>
??
is put in the center or what ever u need to put
slipstream
Forum Commoner
Posts: 86
Joined: Fri Apr 19, 2002 8:53 am
Location: Canada

but

Post by slipstream »

all the data is on the same line, I want to have the output like this

info1 info2 info3 info4

nice and even, I can't use a div there, won't work for each piece of data
User avatar
forgun
Forum Commoner
Posts: 61
Joined: Wed Jan 29, 2003 6:05 am
Contact:

Post by forgun »

so why 3 echos
use one
echo $info[1] .....;
did u try this?
slipstream
Forum Commoner
Posts: 86
Joined: Fri Apr 19, 2002 8:53 am
Location: Canada

but

Post by slipstream »

I did this:

foreach($file as $line)
{
$info = explode('|', $line);

echo " <tr>\n";
echo " <td>" . $info[0] . "</td>";
echo " <td>" . $info[1] . "</td>";
echo " <td>" . $info[2] . "</td>";
echo " <td>" . $info[3] . "</td>";
echo " </tr>\n";

$totHours += $info[2];
}

and it works but the data on each line is too close together, I'd like about 10 spaces between each piece of data, any ideas?
User avatar
bznutz
Forum Commoner
Posts: 58
Joined: Mon Dec 09, 2002 9:52 pm
Location: Here
Contact:

Post by bznutz »

Code: Select all

echo "<table name=t1 cellpadding=3 cellspacing=3>";
foreach($file as $line)
&#123;
$info = explode('|', $line);

echo " <tr>\n";
echo " <td>" . $info&#1111;0] . "</td>";
echo " <td>" . $info&#1111;1] . "</td>";
echo " <td>" . $info&#1111;2] . "</td>";
echo " <td>" . $info&#1111;3] . "</td>";
echo " </tr>\n";

$totHours += $info&#1111;2];
&#125;
Notice my edit at the top. If you want some extra space between data cells, just add more padding and/or spacing to the table parameters.
slipstream
Forum Commoner
Posts: 86
Joined: Fri Apr 19, 2002 8:53 am
Location: Canada

Perfect,

Post by slipstream »

thanks :lol:
Post Reply