Jump to content

Recommended Posts

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

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.