onthespot Posted July 21, 2009 Share Posted July 21, 2009 My messaging system is perfectly fine. I am however having trouble with the navigation for it. <? $userfinal=$_SESSION['username']; $get_messages = mysql_query("SELECT message_id FROM ".TBL_MESSAGES." WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error()); $get_messages2 = mysql_query("SELECT * FROM ".TBL_MESSAGES." WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error()); $num_messages = mysql_num_rows($get_messages); echo '<ul>'; for($count = 1; $count <= $num_messages; $count++) { $row = mysql_fetch_array($get_messages2); ?> <? if($session->logged_in){ ?> <dl class="nav3-grid"> <dt> <? echo "<a href=\"useraccount.php?user=$session->username\">My Account</a>"; ?></dt> <dd> <? echo "<a href=\"userprofile.php?user=$session->username\">My Profile</a>"; ?></dd> <dd> <? echo "<a href=\"usersettings.php\">My Settings</a>"; ?></dd> <dd> <? echo "<a href=\"userjournal.php?user=$session->username\">My Journal</a>"; ?></dd> <? if($row['message_read'] == 0) { ?> <dt> <? echo "<a href=\"messages.php\">My Messages (New)</a>"; ?></dt> <?}else{?> <dt> <? echo "<a href=\"messages.php\">My Messages</a>"; ?></dt> <? }} echo '</ul>'; ?> <dt> <? echo "<a href=\"fixtures.php\">My Fixtures</a>"; ?></dt> <dt> <? echo "<a href=\"results.php\">My Results</a>"; ?></dt> <dt> <? if($session->isAdmin()){ echo "<a href=\"admin/admin.php\">My Admin Panel</a>"; } ?></dt> <dt> <? echo "<a href=\"process.php\">Logout</a>"; ?></dt> </dl> As you can see, I am trying to get the navigation to display (new) next to my messages if there is a new message. Its giving me an error, can anyone see why? Link to comment https://forums.phpfreaks.com/topic/166848-help-with-messages/ Share on other sites More sharing options...
ignace Posted July 21, 2009 Share Posted July 21, 2009 Your navigation shouldn't be in your for() loop. If you want to know if their are new unread messages then use rhodesa's query: http://www.phpfreaks.com/forums/index.php/topic,261409.msg1230839.html#msg1230839. Thus remove the for() loop altogether + any variables you had for it. Link to comment https://forums.phpfreaks.com/topic/166848-help-with-messages/#findComment-879771 Share on other sites More sharing options...
onthespot Posted July 21, 2009 Author Share Posted July 21, 2009 Hey, i got this to work on the normal inbox though.... <?php $userfinal=$_SESSION['username']; $get_messages = mysql_query("SELECT message_id FROM ".TBL_MESSAGES." WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error()); $get_messages2 = mysql_query("SELECT * FROM ".TBL_MESSAGES." WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error()); $num_messages = mysql_num_rows($get_messages); echo '<ul>'; for($count = 1; $count <= $num_messages; $count++) { $row = mysql_fetch_array($get_messages2); if($row['message_read'] == 0) { ?> <table> <tr><td><? echo '<b><a href="read_message.php?messageid=' . $row['message_id'] . '">' . $row['message_title'] . '</a></b><br>';?></td> <td><? echo '<a href="delete_message.php?messageid=' . $row['message_id'] . '">Delete</a><br>';?></td></tr></table> <?}else{?> <table><tr><td><?echo '<a href="read_message.php?messageid=' . $row['message_id'] . '">' . $row['message_title'] . '</a><br>';?></td> <td><?echo '<a href="delete_message.php?messageid=' . $row['message_id'] . '">Del</a><br>';?></td></tr></table><? }} echo '</ul>'; echo '<form name="newmsgfrm" method="post" action="new_message.php">'; echo '<input type="submit" value="Send a New Message">'; echo '</form>'; echo '<form name="backfrm" method="post" action="index.php">'; echo '<input type="submit" value="Back to Home">'; echo '</form>'; ?> That worked a treat! How can I get that to work on the nav? Link to comment https://forums.phpfreaks.com/topic/166848-help-with-messages/#findComment-879775 Share on other sites More sharing options...
ignace Posted July 21, 2009 Share Posted July 21, 2009 Hey, i got this to work on the normal inbox though.... Can be, but it's not the proper way to check if their are any new messages. Memory overkill more likely. Link to comment https://forums.phpfreaks.com/topic/166848-help-with-messages/#findComment-879810 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.