<?php 
include 'check.php';
include '../db.inc.php';
include 'check_msg.php';
$sql="SELECT * FROM messages ORDER BY date DESC";
$query=mysqli_query($connectionString,$sql);
$row=mysqli_num_rows($query);

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Administrator</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="96%" height="421" border="0" cellspacing="5">
  <tr>
    <td width="14%" height="274" valign="top" style="border:#003399 1px solid;"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="21" bgcolor="#de0011" class="headers"><p>Navigation</p></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="1">
          <tr>
            <td bgcolor="#E8FFF8"><p><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="./">Home</a></strong></font></p></td>
          </tr>
           <tr>
            <td bgcolor="#E8FFF8"><p><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="smssender.php">SMS 
              Sender</a></strong></font></p></td>
          </tr>
          <tr>
            <td bgcolor="#E8FFF8"><p><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="add.php">Add 
              User</a></strong></font></p></td>
          </tr>
          <tr>
            <td bgcolor="#E8FFF8"><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="addact.php">Add Activity </a></strong></font></td>
          </tr>
          <tr>
            <td bgcolor="#E8FFF8"><a href="viewact.php"><font size="2" face="Arial, Helvetica, sans-serif"><strong>View Activities </strong></font></a></td>
          </tr>

          <tr>
            <td bgcolor="#E8FFF8"><a href="alerts.php"><font size="2" face="Arial, Helvetica, sans-serif"><strong>View Alerts</strong></font></a></td>
          </tr>
          
          <tr>
            <td bgcolor="#E8FFF8"><a href="sql.php"><font size="2" face="Arial, Helvetica, sans-serif"><strong>SQL</strong></font></a></td>
          </tr>
		  
          <tr>
            <td bgcolor="#E8FFF8"><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="logout.php">Log 
              Out</a></strong></font></td>
          </tr>
        </table>
        <p>&nbsp;</p>
          </td>
      </tr>
    </table>      
      <p>&nbsp;</p>
    </td>
    <td width="86%" valign="top" style="border:#003399 1px solid;"><p><strong><font color="#CC0000" size="2" face="Arial, Helvetica, sans-serif">Total 
        Messages : <?php echo $row; ?></font></strong></p>
      <table width="100%" border="0" cellspacing="1" bgcolor="#de0011">
        <tr align="center" bgcolor="#de0011">
		<td height="25" class="headers">Account</td>
          <td height="25" class="headers">Date</td>
          <td class="headers">Subject</td>
        </tr>
		<?php
		while($get=mysqli_fetch_array($query,MYSQLI_ASSOC)){ ?>
        <tr align="center">
		  <td bgcolor="#E8FFF8"><?php echo $get['number']; ?></td>
		  <td bgcolor="#E8FFF8"><?php echo strftime('%d-%m-%Y %I:%M %p',strtotime($get['date'])); ?></td>
          <td bgcolor="#E8FFF8"><?php if($get['status'] == 0) { ?> <strong><?php echo stripslashes($get['subject']); ?></strong> <?php } else { ?> <?php echo stripslashes($get['subject']); } ?></td>
          <td bgcolor="#E8FFF8"><a href="viewmsg.php?id=<?php echo $get['id']; ?>">View</a></td>
		  <td bgcolor="#E8FFF8"><a href="sendalert.php?user=<?php echo $get['number']; ?>&subject=<?php echo stripslashes($get['subject']); ?>">Reply</a></td>
		  <td bgcolor="#E8FFF8"><a href="deletemsg.php?id=<?php echo $get['id']; ?>">Delete</a></td>
        </tr>
		<?php } ?>
      </table>  
    </td>
  </tr>
</table>


</body>
</html>
