View Full Version : center data in table row
jlsohio
06-19-2003, 02:28 AM
This is part of my PHP code for a HTML page.
The problem I'm having is I cant get the data in the table row to center. Right now the data is left justified. What do I have to add to the code below to center my data in the table row?
Thanks.
jls
$table_row = "<tr>";
$table_row .= "<td WIDTH=24%><font size=\"4\"><font face=\"arial\">$row[Horse]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[Starts]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[First]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[Second]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[Third]</td>";
$table_row .= "<td WIDTH=13%><font size=\"4\"><font face=\"arial\">$row[Record]</td>";
$table_row .= "<td WIDTH=15%><font size=\"4\"><font face=\"arial\">$row[Earnings]</td>";
echo "$table_row\n";
Spookster
06-19-2003, 02:41 AM
Formatting content in your pages is a HTML/CSS issue not a PHP issue. I will move you to that forum...
MotherNatrsSon
06-19-2003, 02:54 AM
Try adding this to your <tr> tag like this
<tr align="center" valign="middle">
That will put it in the middle of the <td> from right to left and top to bottom both.
MNS
jlsohio
06-19-2003, 05:48 PM
It didn't work, got parsing error. This is what I entered:
$table_row = "<tr align="center" valign="middle">";
$table_row .= "<td WIDTH=24%><font size=\"4\"><font face=\"arial\">$row[Horse]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[Starts]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[First]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[Second]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[Third]</td>";
$table_row .= "<td WIDTH=13%><font size=\"4\"><font face=\"arial\">$row[Record]</td>";
$table_row .= "<td WIDTH=15%><font size=\"4\"><font face=\"arial\">$row[Earnings]</td>";
echo "$table_row\n";
Then I tried it like this:
$table_row = "<tr>";
$table_row .= "<td align="center" valign="middle WIDTH=24%><font size=\"4\"><font face=\"arial\">$row[Horse]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[Starts]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[First]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[Second]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[Third]</td>";
$table_row .= "<td WIDTH=13%><font size=\"4\"><font face=\"arial\">$row[Record]</td>";
$table_row .= "<td WIDTH=15%><font size=\"4\"><font face=\"arial\">$row[Earnings]</td>";
echo "$table_row\n";
Spookster
06-19-2003, 06:30 PM
You need to escape quotation marks
align=\"center\" valign=\"middle\">
MotherNatrsSon
06-19-2003, 06:42 PM
Sorry about that...wasn't paying attention.
$table_row = "<tr align=\"center\" valign=\"middle\">";
$table_row .= "<td WIDTH=24%><font size=\"4\"><font face=\"arial\">$row[Horse]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[Starts]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[First]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[Second]</td>";
$table_row .= "<td WIDTH=12%><font size=\"4\"><font face=\"arial\">$row[Third]</td>";
$table_row .= "<td WIDTH=13%><font size=\"4\"><font face=\"arial\">$row[Record]</td>";
$table_row .= "<td WIDTH=15%><font size=\"4\"><font face=\"arial\">$row[Earnings]</td>";
echo "$table_row\n";
That should get you what you need
MNS
You might need to escape those closing tags as well...
So </td> simply becomes <\/td>
Spookster
06-19-2003, 09:10 PM
Originally posted by giz
You might need to escape those closing tags as well...
So </td> simply becomes <\/td>
Those won't affect it. These are strings so the only characters that have the potential to affect the string are single or double quotes and backslashes.
jlsohio
06-19-2003, 11:33 PM
Thanks guys,
It works great!
jls
>> Those won't affect it. <<
My bad. It's javascript where you must escape those.
Going back to sleep.....
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.