Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 16th, 2014, 06:25 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
  #2 (permalink)  
Old September 24th, 2014, 04:35 AM
Friend of Wrox
Points: 651, Level: 9
Points: 651, Level: 9 Points: 651, Level: 9 Points: 651, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: North East UK
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>";
}
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 07:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.