Solved

PHP Align Center Code Issue

Posted on 2011-03-04
3
718 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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

777 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