Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 733
  • Last Modified:

PHP Align Center Code Issue

I can't get the display results to align in the center when displayed in a browser....what is wrong with my code?
<?php
$con = mysql_connect("localhost","uname","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("mydatabase", $con);

$result = mysql_query("SELECT * FROM mytable");

echo "<table border='6'>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Status</th>
<th></th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" align="center". $row['fname'] . "</td>";
  echo "<td>" align="center". $row['lname'] . "</td>";
  echo "<td>" align="center". $row['status'] . "</td>";
  echo "</tr>";
  }
echo "</table>";


?>

Open in new window

0
wantabe2
Asked:
wantabe2
  • 2
1 Solution
 
mars-vieCommented:
Change to
echo "<td align='center'>". $row['fname'] . "</td>";

Regards,
MARS-VIE
0
 
mars-vieCommented:
Of course you have to change all <td> tags to <td align='center'>

:-)
0
 
Lukasz ChmielewskiCommented:
... or use css for all the td's
td{text-align: center;}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now