Forum Moderators: open

Message Too Old, No Replies

Table positioning assitance sought

Tables

         

garywhite glw

2:34 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



Hi again. I've got code working to produce a simple a column table but what I'm unable to achieve is to get the table to appear where I want it on the page. At the moment it always appears in the top left. How can I be specific about exactly where it appears? The code I have (that works) is below:

<?php
echo "<table>";
while ($row = mysql_fetch_array($result)){

echo "<tr><td>".$row['Firstname']." </td></tr><tr><td>".$row['email']." </td></tr><tr><td> ".$row['Phone']." </td></tr>";

}
echo "</table>";

?>

Any help appreciated
Cheers
Gary

rocknbil

6:57 pm on Jan 4, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




echo "<table id=\"some-table-id\">";

Then in your CSS,

#some-table-id {
width: 75%;
max-width:750px; /* or whatever, 75% on large rez. may be illegible */
margin:auto;
}

Should center it on the page.

garywhite glw

10:34 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



I've tried your code as follows:

In between the head tags:
#some-table-id {
width: 75%;
max-width:750px; /* or whatever, 75% on large rez. may be illegible */
margin:auto;
}

At the end of the page:
echo "<table id=\"some-table-id\">";
while ($row = mysql_fetch_array($result)){

echo "<tr><td>".$row['Firstname']." </td></tr><tr><td>".$row['email']." </td></tr><tr><td> ".$row['Phone']." </td></tr>";
}
echo "</table>";

?>

The result is the table still at the top left of the page but preceded by the #some-table-id lines just above it...

I'm obviously doing something stupid.

Again.

rocknbil

7:34 am on Jan 5, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well it should work . . did you include the style tags?

<style type="text/css">
#some-table-id {
width: 75%;
max-width:750px;
margin:auto;
}
</style>
</head>

I just assumed . . . sorry.