使新条目显示为粗体
Make new entries appear bold
我正在尝试创建一个类似电子邮件的系统,其中已读邮件显示正常,新 entries/messages 显示为粗体。我创建了一个 css 规则来满足文本格式,但我遇到的问题是在我的循环中实现它。
谢谢
$stmt = $pdo->query("SELECT * FROM $tbl_name");
$stmt->execute();
$num_rows = $stmt->rowCount();
print "<p>$num_rows Record(s) Found.</p>";
echo "<table width='100%' border='1' bordercolor='#0cc' cellspacing='0' cellpadding='2'>";
echo "<tr>
<th bgcolor='#444444' align='center'><font color='#fff'>Surname</font></th>
<th bgcolor='#444444' align='center'><font color='#fff'>Firstname</font></th>
<th bgcolor='#444444' align='center'><font color='#fff'>Email / Username</th>
<th bgcolor='#444444' align='center'><font color='#fff'>Phone</th>
<th bgcolor='#444444' align='center'><font color='#fff'>Date Registered</th>
<th bgcolor='#444444' align='center'><font color='#fff'>Status</th>
<th bgcolor='#444444' align='center'><font color='#fff'>Create Account</th>
<th bgcolor='#444444' align='center'><font color='#fff'>Delete Account</th>
</tr>";
// keeps getting the next row until there are no more to get
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$clas = $row['entry'];
if($clas == 'NEW'){
$style = "<div style='font-weight:bold'></div>";
}else{
$style = "<div style='font-weight:normal'></div>";
}
// Print out the contents of each row into a table
echo "<tr><td>";
echo ucfirst($row['surname']);
echo "</td><td>";
echo ucfirst($row['firstname']);
echo "</td><td>";
echo $row['email'];
echo "</td><td>";
echo $row['phone'];
echo "</td><td>";
echo $row['today'];
echo "</td><td>";
echo $row['status'];
echo "</td><td>";
echo "<a href='create-account.php?id={$row['id']}'>Create Account</a>";
echo "</td><td>";
echo "<a href='account-delete.php?id={$row['email']}'>Delete Account</a>";
echo "</td></tr>";
}
echo "</table>";
这可能是您想要实现的目标,但下次请提出正确的问题。
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$clas = $row['entry'];
if($clas == 'NEW'){
$style = ' style="font-weight:bold"';
}
// Print out the contents of each row into a table
echo "<tr{$style}><td>";
echo ucfirst($row['surname']);
echo "</td><td>";
echo ucfirst($row['firstname']);
echo "</td><td>";
echo $row['email'];
echo "</td><td>";
echo $row['phone'];
echo "</td><td>";
echo $row['today'];
echo "</td><td>";
echo $row['status'];
echo "</td><td>";
echo "<a href='create-account.php?id={$row['id']}'>Create Account</a>";
echo "</td><td>";
echo "<a href='account-delete.php?id={$row['email']}'>Delete Account</a>";
echo "</td></tr>";
}
我正在尝试创建一个类似电子邮件的系统,其中已读邮件显示正常,新 entries/messages 显示为粗体。我创建了一个 css 规则来满足文本格式,但我遇到的问题是在我的循环中实现它。
谢谢
$stmt = $pdo->query("SELECT * FROM $tbl_name");
$stmt->execute();
$num_rows = $stmt->rowCount();
print "<p>$num_rows Record(s) Found.</p>";
echo "<table width='100%' border='1' bordercolor='#0cc' cellspacing='0' cellpadding='2'>";
echo "<tr>
<th bgcolor='#444444' align='center'><font color='#fff'>Surname</font></th>
<th bgcolor='#444444' align='center'><font color='#fff'>Firstname</font></th>
<th bgcolor='#444444' align='center'><font color='#fff'>Email / Username</th>
<th bgcolor='#444444' align='center'><font color='#fff'>Phone</th>
<th bgcolor='#444444' align='center'><font color='#fff'>Date Registered</th>
<th bgcolor='#444444' align='center'><font color='#fff'>Status</th>
<th bgcolor='#444444' align='center'><font color='#fff'>Create Account</th>
<th bgcolor='#444444' align='center'><font color='#fff'>Delete Account</th>
</tr>";
// keeps getting the next row until there are no more to get
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$clas = $row['entry'];
if($clas == 'NEW'){
$style = "<div style='font-weight:bold'></div>";
}else{
$style = "<div style='font-weight:normal'></div>";
}
// Print out the contents of each row into a table
echo "<tr><td>";
echo ucfirst($row['surname']);
echo "</td><td>";
echo ucfirst($row['firstname']);
echo "</td><td>";
echo $row['email'];
echo "</td><td>";
echo $row['phone'];
echo "</td><td>";
echo $row['today'];
echo "</td><td>";
echo $row['status'];
echo "</td><td>";
echo "<a href='create-account.php?id={$row['id']}'>Create Account</a>";
echo "</td><td>";
echo "<a href='account-delete.php?id={$row['email']}'>Delete Account</a>";
echo "</td></tr>";
}
echo "</table>";
这可能是您想要实现的目标,但下次请提出正确的问题。
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$clas = $row['entry'];
if($clas == 'NEW'){
$style = ' style="font-weight:bold"';
}
// Print out the contents of each row into a table
echo "<tr{$style}><td>";
echo ucfirst($row['surname']);
echo "</td><td>";
echo ucfirst($row['firstname']);
echo "</td><td>";
echo $row['email'];
echo "</td><td>";
echo $row['phone'];
echo "</td><td>";
echo $row['today'];
echo "</td><td>";
echo $row['status'];
echo "</td><td>";
echo "<a href='create-account.php?id={$row['id']}'>Create Account</a>";
echo "</td><td>";
echo "<a href='account-delete.php?id={$row['email']}'>Delete Account</a>";
echo "</td></tr>";
}