I am trying to get data to display on a webpage. I have everything working but I cannot get the table cells to stay a consistent width. I've tried setting each cell to a specififc width - didn't work. I tried wrapping the text - didn't work. I've been at it for hous - pleeeeaaaassssseeee help.
Here's my CSS code:
<style type="text/css">
<!--
.display {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
color: #242424;
background-color: #FFFFFF;
text-align: left;
vertical-align: top;
padding: 4px;
}
.mainTable {
background-color: #BEBEBE;
padding: 3px;
}
-->
</style>
... and here's the PHP:
<table cellspacing="1" class="mainTable">
<tr>
<td width="50px" class="display">ID</td>
<td width="150px" class="display">Name</td>
<td width="150px" class="display">Name (2)</td>
<td width="450px" class="display">Address</td>
<td width="70px" class="display">Phone</td>
<td width="200px" class="display">Email</td>
<td width="80px" class="display">Exp Date</td>
<td width="80px" class="display">Membership Type</td>
<td width="120px" class="display">Child(ren)'s Name(s)</td>
<td width="300px" class="display">Interests</td>
<td width="80px" class="display">Date added</td>
<td width="80px" class="display">added</td>
<td width="150px" class="display">Additional</td>
</tr></table>
<?php
$sql = mysql_query( "SELECT * FROM memberships" )
or die("SELECT Error: ".mysql_error());
// start the while statement to get results from database
while ($row = mysql_fetch_array($sql)) {
// foreach row in the while loop..
foreach($row as $key=>$value){
// convert the long winded $row[''] to simple variable
// also cleaning the data of slashes for security ValidateOutput() (look at clean.php)
$$key = ValidateOutput($value);
}
// display data in an HTML table for viewing
echo '<table cellspacing="1" class="mainTable">
<tr>
<td class="display">'.$memberID.'</td>
<td class="display">'.$firstName.' '.' '.$lastName.'</td>
<td class="display">'.$firstName2.' '.' '.$lastName2.'</td>
<td class="display">'.$address.' '.' '.$city.' '.' '.$state.' '.' '.$zip.'</td>
<td class="display">'.$telephone.'</td>
<td class="display">'.$email.'</td>
<td class="display">'.$expiration.'</td>
<td class="display">'.$type.'</td>
<td class="display">'.$childName.'</td>
<td class="display">'.$interests.'</td>
<td class="display">'.$dateAdded.'</td>
<td class="display">'.$added.'</td>
<td class="display">'.$additionalNotes.'</td>
</tr>
</table>';
}
?>
Here's the results: http://flw.org/memberships/admin/index.php
I want all the cells to line up in each row