Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 16th, 2014, 05:25 AM
Registered User
 
Join Date: May 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default mark read/unread message in php

hi, i am developing messaging system in php. i am able to retrieve messages stored in mysql but not able to mark unread message in bold

this code will retrive data from mysql table and display result in table format.
I want unread message to be shown in bold letter and read message in normal text.

In my table i have msg_read column which is set to '0' if message is unread and '1' if message is already read by user.

echo "<table border='1' cellpadding='10'>";
echo "<tr><th>From</th> <th>Subject</th> <th>Date</th></tr>";
// loop through results of database query, displaying them in the table

while($row = mysqli_fetch_array($selectresult))
{
// echo out the contents of each row into a table

echo "<tr style=''>";
echo '<td>' . $row['from_user'] . '</td>';
echo '<td>' . $row['message_title'] . '</td>';
echo '<td>' . $row['date'] . '</td>';
echo '<td><a href="?page_id=1174&MI=' . $row['message_id'] . '">Read</a> </td>';
echo '<td><a href="?page_id=1301&MI=' . $row['message_id'] . '">Delete</a> </td>';
echo "</tr>";


}


// close table>
echo "</table>";

Please if someone can help Thank You.
 
Old September 24th, 2014, 03:35 AM
Friend of Wrox
 
Join Date: May 2011
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

One way to do it;
Code:
while($row = mysqli_fetch_array($selectresult))
{
	// setup formatting
	$bold = ( !$row['msg_read'] ? 'font-weight: bold;' : '');
	
	// echo out the contents of each row into a table
	echo "<tr style=''>";
	echo '<td style="' . $bold . '">' . $row['from_user'] . '</td>';
	echo '<td style="' . $bold . '">' . $row['message_title'] . '</td>';
	echo '<td style="' . $bold . '">' . $row['date'] . '</td>';
	echo '<td><a href="?page_id=1174&MI=' . $row['message_id'] . '">Read</a> </td>';
	echo '<td><a href="?page_id=1301&MI=' . $row['message_id'] . '">Delete</a> </td>';
	echo "</tr>";
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
Mark a USB Drive a Read Only. dparsons C# 2005 0 May 2nd, 2007 01:23 PM
VB / Lotus - Mark messages as read/unread gattsi Pro VB 6 3 August 7th, 2006 06:26 AM
Read Error Message djuricd SQL Server 2000 2 September 21st, 2004 11:02 AM
changing the status of the message (read / unread) neomohlala SQL Server 2000 0 August 13th, 2003 04:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.