$db = mysql_select_db("qr");
$SQL = "SELECT * FROM document AS d1
INNER JOIN department AS d2 ON (d1.to_dep_id = d2.dep_id)
INNER JOIN position AS d3 ON (d1.to_pos_id = d3.pos_id)
INNER JOIN user AS d4 ON (d1.to_pos_id = d4.pos_id)
WHERE doc_name = '$docname'";
$Query = mysql_query($SQL);
$Result = mysql_fetch_array($Query);