Esta es toda la pagina 
 
No entiendo bien que quieres decir 
la tabla folder tiene algo asi
1 enviados
2 recibidos
3 favoritos
4 eliminados
la tabla messages te la he puesto al principio    
Código PHP:
Ver original<?php require_once('Connections/libre.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
  }
 
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? 
intval($theValue) : "NULL";       break;
    case "double":
      $theValue = ($theValue != "") ? 
doubleval($theValue) : "NULL";       break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); }
 
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {   $insertSQL = sprintf("INSERT INTO messages (subject, body, `to`, `from`, sended_on, `read`, folder_id, owner) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",                        GetSQLValueString($_POST['subject'], "text"),
                       GetSQLValueString($_POST['body'], "text"),
                       GetSQLValueString($_POST['to'], "int"),
                       GetSQLValueString($_POST['from'], "int"),
                       GetSQLValueString($_POST['sended_on'], "date"),
                       GetSQLValueString($_POST['read'], "int"),
                       GetSQLValueString($_POST['folder_id'], "int"),
                       GetSQLValueString($_POST['owner'], "int"));
 
 
  $insertGoTo = "acceso.php";
  if (isset($_SERVER['QUERY_STRING'])) {     $insertGoTo .= (strpos($insertGoTo, '?')) ? 
"&" : "?";     $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
}
 
$query_menssages = "SELECT * FROM messages";
 
$query_usuario = "SELECT * FROM libre";
 
$query_carpetas = "SELECT * FROM folders";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/base.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>base</title>
<!-- InstanceEndEditable -->
<link href="tables.css" rel="stylesheet" type="text/css" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<style type="text/css">
body {
    background-image: url();
    background-color: #D3E4E5;
}
.centro {
    text-align: center;
}
irq {
    text-align: left;
}
</style>
</head>
 
<body bgcolor="#D3E4E5">
<table width="54" border="0" align="center" cellpadding="3" cellspacing="0">
  <tr>
    <td align="center" valign="middle" class="centro"><img src="imagen/logo_final_.jpg" width="877" height="195" align="middle" />
      <Marquee  style="font-size: 16px; color:#000" 
bgcolor="#B6C34F"  >
    </Marquee>      <br /></td>
  </tr>
  <tr>
    <td><!-- InstanceBeginEditable name="panel de control" -->
      <p> </p>
      <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
        <table width="610" align="center">
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Descriccion:</td>
            <td><input type="text" name="subject" value="" size="50" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Texto:</td>
            <td><textarea name="body" cols="50" rows="5"></textarea></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right"> </td>
            <td><input type="submit" class="rojo" value="Insertar mensaje" /></td>
          </tr>
        </table>
        <input type="hidden" name="to" value="<?php echo $row_usuario['usuario_id']; ?>" />
        <input type="hidden" name="from" value="<?php echo $row_menssages['id']; ?>" />
        <input type="hidden" name="sended_on" value="<?php echo $row_menssages['sended_on']; ?>" />
        <input type="hidden" name="read" value="0" />
        <input type="hidden" name="folder_id" value="<?php echo $row_carpetas['id']; ?>" />
        <input type="hidden" name="owner" value="<?php echo $row_menssages['id']; ?>" />
        <input type="hidden" name="MM_insert" value="form1" />
      </form>
      <p> </p>
<p> </p>
    <!-- InstanceEndEditable --></td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
<?php
 
 
?>