<?php
require_once('header.php');
require_once('check_user.php');

$sql    = "select * from {$tablepre}category where category_status=1 and category_parentid=0 order by category_order asc";
$rscate = $db->get_all($sql);

$scuser_id = $_SESSION["uid"];
$msg_id    = intval($_GET["msg_id"]);
//$sql = "select * from {$tablepre}message where msg_poster='".$scuser_id."' and msg_id='".$msg_id."'";

$sql="select m.*,pic.attach_path,c.category_parentid,c.category_name from {$tablepre}message m 
      inner join {$tablepre}categorymng cm on m.msg_id=cm.msg_id 
	  inner join {$tablepre}attachmng pic ON pic.msg_id = m.msg_id and pic.category_id = cm.category_id
      inner join {$tablepre}category c on c.category_id=cm.category_id where m.msg_poster='".$scuser_id."' and m.msg_id='".$msg_id."'";
$row = $db->get_row($sql);

$category_parentid = $row['category_parentid'];
$category_id       = $row['category_id'];
$category_name     = $row['category_name'];
$attach_path       = $row['attach_path'];

$msg_title         = $row['msg_title'];
$msg_downurl       = $row['msg_downurl'];
$msg_integral      = $row['msg_integral'];
$msg_demourl       = $row['msg_demourl'];
$msg_content       = $row['msg_content'];

$sql     = "select * from {$tablepre}category where category_status=1 and category_parentid='".$category_parentid."' order by category_order asc";
$rscate2 = $db->get_all($sql);

include($template->getfile('edit_publish'));
?>