Jump to content

HELP with email INBOX screen


rsammy

Recommended Posts

i am working an application that involves sending and receiving emails from the system. the existing system shows email ids, subject and details in the inbox screen - say, [email protected]. these three items are shown as links and cliking the link will load the email body.

here is the existing code :

[code=php:0]
if ($user_auth == "2")
{
  $queryz="SELECT message, user_id, status, from_p, subject,
  DATE_FORMAT(received, '%m/%d/%Y') as date, ID, to_email, time_sent, grp_id FROM messages WHERE received >='$dbdates' and 
  received <='$dbdate' order by ID DESC ";

  $querysent="SELECT messages.message, messages.user_id, messages.status, messages.from_p, messages.subject, DATE_FORMAT
  (messages.received, '%m/%d/%Y') as date, messages.ID, messages.to_email, messages.time_sent, messages.grp_id FROM
  messages, sent_messages WHERE messages.received >='$dbdates' and messages.received <='$dbdate' and messages.id =
  sent_messages.message_id and sent_messages.user_id='$userid' order by messages.ID DESC";
}
else
{
  $queryz = "SELECT message, user_id, status, from_p, subject, DATE_FORMAT(received, '%m/%d/%Y') as date, ID, to_email,
  time_sent, grp_id FROM messages WHERE request !='settodelete' AND user_id='$userid'  and received >='$dbdates' and received
  <='$dbdate' order by ID DESC ";

  $querysent="SELECT messages.message, messages.user_id, messages.status, messages.from_p, messages.subject, DATE_FORMAT
  (messages.received, '%m/%d/%Y') as date, messages.ID, messages.to_email, messages.time_sent, messages.grp_id FROM
  messages, sent_messages WHERE messages.request !='settodelete' AND messages.user_id='$userid' and messages.received
  >='$dbdates' and messages.received <='$dbdate' and messages.id = sent_messages.message_id and sent_messages.user_id='$userid'
  order by messages.ID DESC";
}
  $resultz = mysql_query($queryz);
  $num_rowz = mysql_num_rows($resultz);
  $rowz= mysql_fetch_array($resultz);

  $inboxcounter = $num_rowz;
  $from_p = $rowz["from_p"];

HTML display:

<tr>
  <td colspan="2" bordercolor="#006699" bgcolor="#0089B7"></td>
  <td width="34" bordercolor="#006699" bgcolor="#0089B7"></td>
  <td width="231" bordercolor="#006699" bgcolor="#0089B7"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"
            color="#FFFFFF"><b>From</b></font></td>
  <td width="175" bordercolor="#006699" bgcolor="#0089B7"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"
            color="#FFFFFF"><b>Subject</b></font></td>
  <td width="107" bordercolor="#006699" bgcolor="#0089B7"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"
            color="#FFFFFF"><b>Received</b></font></td>
  <td width="13" bordercolor="#006699" bgcolor="#0089B7"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"
            color="#FFFFFF">&nbsp;</font></td>
</tr>
<?PHP
$num_results=mysql_num_rows($resultz);
$i=1;
if(!isset($rowNum))
{
$rowNum = 0;
}
$rowNumHold = $rowNum;
$count = 1;
$limit_results = 25;
if ($num_rowz > 0)
{
  for($q=0;$q<$limit_results && $rowNum < $num_rowz;$q++)
  {
      if(mysql_data_seek($resultz, $rowNum++))
      {
if ($i++%2)
{
  print ("<tr  bgcolor=\"#cccccc\">");
}
else
{
  print ("<tr>");
}
if ($rowz = mysql_fetch_array($resultz))
{
?>

  <td colspan="2">&nbsp;</td>
  <td>
    <?PHP

if($rowz["status"] == 1)
{
  print("<img src=\"images/unopened-icon.gif\" width=\"18\" height=\"18\" border=\"0\">");
}
else
{
  print("<img src=\"images/opened-icon.gif\" width=\"18\" height=\"18\" border=\"0\">");
}
?>
<td><a href="view.php<?PHP
              print("?mess_id=".$rowz                                        ["ID"]. "&m1=".$m1. "&d1=".$d1 . "&y1=".$y1. "&m2=".$m2 . "&d2=".$d2 . "&y2=".$y2 . "&incount=".$inboxcounter . "&sentcount=".$sentcounter );
                                ?>" >
        <?PHP
print($rowz["from_p"]);

/*$queryfrom = "SELECT user_fname, user_lname, user_email FROM user_mgr WHERE
                                      user_email='$from_p' ";
//echo "$query";
$resultfrom = mysql_query($queryfrom);
$rowfrom = mysql_fetch_array($resultfrom);
//print($queryfrom);
$fname= $rowfrom["user_fname"];
$lname=$rowfrom["user_lname"];
//$uname = $user_fname ." ". $user_lname;
$uname = $fname ." ". $lname;
print ($uname);
*/
      ?></a></td>
<td><a href="view.php<?PHP print("?mess_id=".$rowz["ID"]. "&m1=".$m1. "&d1=".$d1 . "&y1=".$y1. "&m2=".$m2 . "&d2=".$d2 . "&y2=".$y2 . "&incount=".$inboxcounter . "&sentcount=".$sentcounter  ); ?>"><?PHP print($rowz["subject"]); ?></a></td>
  <td><a href="view.php<?PHP print("?mess_id=".$rowz["ID"]. "&m1=".$m1. "&d1=".$d1 . "&y1=".$y1. "&m2=".$m2 . "&d2=".$d2 . "&y2=".$y2 . "&incount=".$inboxcounter . "&sentcount=".$sentcounter  ); ?>"><?PHP print($rowz["date"]."&nbsp;&nbsp;".$row["time_sent"]); ?></a></td>
      <!--<a href=\"Recorddetails.php?visit_id=$row->visit_id&visit_type=ICN&client_id=$row->client_id&visit_status=$row->visit_status&visit_loc=$row->visit_loc&pat_first_name=$row->pat_first_name&pat_last_name=$row->pat_last_name&phy_fname=$row->phy_fname&phy_lname=$row->phy_lname&pat_dob=$row->pat_birthday&pat_ssn=$row->pat_ssn&pat_sex=$row->pat_sex\">$row->diag_diag</a>-->
  <td colspan="8">&nbsp;</td>
</tr>
<?
        }

  }
}

?>
[/code]
**********

i was trying execute a qeury at thepoint where we are displaying from_p(email address of sender) to display name of the sender(code that i left commented there).

something is wrong inthis code. it displays thename but, it displays the same name (the name on top of the list) for all the emails irrespective of whom it came from.

i need help in fixing this. any help will be greatly appreciated.
Link to comment
https://forums.phpfreaks.com/topic/27506-help-with-email-inbox-screen/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.