PHP/Mysql displaying certain results in bold
I have a members section on a site I'm doing that allows users to send PMs to one another, I have all this bit set up and working fine.
What I want to do is have any unread PMs in bold and any tread PMs not in bold (basically the same way as most PM systems/email work).
I have created it so that when a user has read the PM that the variable "viewed" is updated to be the value of 1 (unread PMs are 0).
PHP Code:
$query = "SELECT * FROM userspm WHERE user='$user' ORDER BY messageid DESC LIMIT $limitvalue, $limit";
$result = mysql_query($query) or die("Error: " . mysql_error());
if(mysql_num_rows($result) == 0){
echo("No Private Messages");
}
$bgcolor = "#FFFFFF"; //
$bgcolor2 = "#BFDFFF"; //
$bgcolor3 = "#FFCC33"; //
$bgcolor4 = "#FFDF80"; //
$bgcolor5 = "#FFEEB9"; //
$font = "Verdana, Arial, Helvetica, sans-serif"; //
$fontsize = "2"; //
$tdwidth = "150"; //
$tdwidth2 = "300"; //
echo("<table>");
echo("<tr bgcolor=".$bgcolor.">\n<td>");
echo("<td width=".$tdwidth." bgcolor=".$bgcolor.">");
echo("<font face=".$font."><B>");
echo("<font size=".$fontsize.">");
echo('Sender');
echo("<td width=".$tdwidth2." bgcolor=".$bgcolor.">");
echo("<font face=".$font.">");
echo("<font size=".$fontsize."><B>");
echo('Subject');
echo("<td width=".$tdwidth." bgcolor=".$bgcolor.">");
echo("<font face=".$font.">");
echo("<font size=".$fontsize."><B>");
echo('Date');
while($row = mysql_fetch_array($result)){
if ($bgcolor == "#FFFFFF"){
$bgcolor = "#FFFFFF";
}else{
$bgcolor = "#FFFFFF";
}
echo("<tr bgcolor=".$bgcolor.">\n<td>");
echo("<td width=".$tdwidth." bgcolor=".$bgcolor.">");
echo("<font face=".$font.">");
echo("<font size=".$fontsize.">");
echo('' . $row["username"] . '');
echo("<td width=".$tdwidth2." bgcolor=".$bgcolor.">");
echo("<font face=".$font.">");
echo("<font size=".$fontsize.">");
echo('<a href="http://www.mysite.com/read-message.php?mid=' . $row["messageid"] . '">' . $row["pmtitle"] . '</a></div>');
echo("<td width=".$tdwidth." bgcolor=".$bgcolor.">");
echo("<font face=".$font.">");
echo("<font size=".$fontsize.">");
echo('' . $row["date"] . '');
}
echo("</table>");
?></font>
Is anyone able to help please?!
Cheers
Wardy
|