PHP HTML table is too wide
- by typoknig
I have a table that I cannot get to size correctly. The table populates with information from a database via a loop. Sometimes if the data is too long the table extends past where it should. When the data is that long I want the data to wrap in the cells so the table stays where it should. I have tried the normal table data but it isn't working. Any ideas?
<?php
echo "<table>
<tr>
<th>id</th>
<th>700-number</th>
<th>First name</th>
<th>Last name</th>
<th>Email</th>
<th>Response</th>
<th>Created On</th>
</tr>";
$num = mysql_num_rows($result);
for ($i = 0; $i < $num; $i++)
{
$row = mysql_fetch_array($result);
$id = $row['id'];
$school_id = $row['school_id'];
$fname = $row['first_name'];
$lname = $row['last_name'];
$email = $row['email'];
$attending = ($row['attending'] == 0) ? 'No' : 'Yes';
$date = $row['created_on'];
$class = (($i % 2) == 0) ? "td2" : "td1";
echo "<tr>";
echo "<td class=" . $class . ">$id</td>";
echo "<td class=" . $class . ">$school_id</td>";
echo "<td class=" . $class . ">$fname</td>";
echo "<td class=" . $class . ">$lname</td>";
echo "<td class=" . $class . ">$email</td>";
echo "<td class=" . $class . ">$attending</td>";
echo "<td class=" . $class . ">$date</td>";
echo "</tr>";
}
?>
</table>