Here’s the code:
<?php
mysqlLogin();
$username = $_COOKIE['username'];
$sql = mysql_query("SELECT username FROM `users` WHERE username!='$username'");
if(mysql_num_rows($sql) != 0) {
echo "<table class='usertable' align='center'>";
} else {
echo "<center>No users found!</center>";
}
while($row = mysql_fetch_array($sql)){
$length = strlen($row['username']) . 'px';
echo "<tr><td style='width: '$length'; border-bottom: 1px solid #000000'><center>" . $row['username'] . "</center></td></tr>";
}
?>
I want to make the bottom-border the length of the longest username in the SQL database.
This makes no sense… a border directive in CSS has no length – it automatically assumes the length/height of the element it’s a border of.
If you mean you want to indicate which particular cell has the longest username and highlight it with a border-bottom, then you’d need to know in advance which username is longest. You can’t have PHP “recall” the HTML it’s already output to add the border directive after the fact.