Log in

View Full Version : Overflowing tables



Schmoopy
02-21-2009, 12:04 PM
Hey, I want to make a table overflow so that elements within it just stop... so then I can add "..." to the end of them. I'm working in a limited <div> space so for example "This is some text and it's very long" just becomes "This is some text..." and overflow it like that. I'm just not sure how to go around it.

Here's what I have so far:

CSS:



.boxcontent table{
border-width: 1px 1px 1px 1px;
border-spacing: 2px;
border-style: none none none none;
border-collapse:collapse;
background-color:#458BDD;
width:100%;
}
.boxcontent table th {
border-width: 1px 1px 1px 1px;
padding: 4px 4px 4px 4px;
border-style: none none none none;
}

.boxcontent table tr.data{
border-top:1px solid black;
}

.boxcontent table td {
border-width: 1px 1px 1px 1px;
padding: 8px 8px 8px 8px;
border-style: none none none none;
}


HTML (just ignore the PHP):



<div id="appointments">
<div class="title">
Appointments
</div>
<br />
<div class="hr"></div>
<div class="boxcontent">
<?php
$query = mysql_query("SELECT * FROM appointments WHERE date = '$datenow' ORDER BY date, time");

if (mysql_num_rows($query))
{
echo "<table><tr class=\"headings\"><td>Name</td><td>When</td><td>Where</td></tr>";
while($row = mysql_fetch_array($query))
{
"<tr class=\"data\"><td>" . $row['name'] . "</td><td>" . $row['time'] . "</td><td>" . $row['where'] . "</td></tr>";
}
echo "</table>";
}

else{
echo "No appointments scheduled.";
}


?>
</div>
</div>

Schmoopy
02-21-2009, 02:31 PM
Anyone? I need to get this done quickly :p

magicyte
02-21-2009, 03:24 PM
I'm not sure if this is able to be done with CSS, but possibly PHP. You can figure out the amount of characters in a string using strlen(). If it exceeds your character limit, you can cut the rest of the string off somehow and add a '...'. Do this with the DB information and it should be easy.

Is this what you wanted?

Schmoopy
02-21-2009, 03:30 PM
OMG what a fool I've been... of course, thanks! :D

magicyte
02-21-2009, 03:38 PM
You're welcome. :)