?
Solved

PHP Align Center Code Issue

Posted on 2011-03-04
3
Medium Priority
?
728 Views
Last Modified: 2012-05-11
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
Comment
Question by:wantabe2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Expert Comment

by:mars-vie
ID: 35037890
Change to
echo "<td align='center'>". $row['fname'] . "</td>";

Regards,
MARS-VIE
0
 
LVL 4

Accepted Solution

by:
mars-vie earned 2000 total points
ID: 35037907
Of course you have to change all <td> tags to <td align='center'>

:-)
0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 35038097
... or use css for all the td's
td{text-align: center;}
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Find out what you should include to make the best professional email signature for your organization.
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question