Solved

PHP Align Center Code Issue

Posted on 2011-03-04
3
724 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
  • 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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

839 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