<HTML>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=x-euc-jp">
<HEAD>
<TITLE>PHP BBS</TITLE>
</HEAD>
<body bgcolor="#ff6666">

<?
$sequence
="ugeuge";
$table="mogemoge";
$database=pg_Connect("","","","","test1");
$ip=getenv("REMOTE_ADDR");
$datetime=date("Y-n-j H:i:s");
$name=i18n_convert($name,"EUC");
$title=i18n_convert($title,"EUC");
$mail=i18n_convert($mail,"EUC");
$contents=i18n_convert($contents,"EUC");
if(
$button == "書き込み") {
    
$strSQL="insert into $table values(nextval('$sequence'),'$parent_number','$title','$contents','$name','$ip','$datetime','$mail')";
    
pg_exec($database,$strSQL);
    unset(
$title,$name,$contents,$ip,$datetime,$mail);
    
$parent_number=0;
    include(
"write4.php");
    
Show_Titles();
}
else if(isset(
$print_number)) {
    include(
"show_contents4.php");
    
$parent_number=$print_number;
    include(
"write4.php");
}
else {
    
$parent_number=0;
    include(
"write4.php");
    
Show_Titles();
}
function 
Show_Titles() {
    print (
"<b>投稿一覧</b><br><br>");
    
Show_Itself_And_Call_Children(0,-1);
}

function 
Show_Itself_And_Call_Children($number,$indent) {
    global 
$database,$table;
    if(
$number != 0) {
    
$result=pg_exec($database,"select * from $table where number='$number'");
    for(
$i=0;$row=@pg_fetch_array($result,$i);$i++) {
        
$name=$row["name"];
        
$title=$row["title"];
        
$datetime=$row["datetime"];
        
$mail=$row["mail"];
        print 
str_repeat("-",$indent);
        print (
"$number: <a href=\"bbs4.php?print_number=$number\">$title</a> : ");
        if(isset(
$mail) && $mail!="") print ("<a href=\"mailto:$mail\">");
        print (
"$name");
        if(isset(
$mail) && $mail!="") print ("</a>");
        print (
" :$datetime");
        print (
"<br>");
    }
    }
    
//子供呼出
    
$result=pg_exec($database,"select * from $table where parent_number='$number'");
    for(
$i=0;$row=@pg_fetch_array($result,$i);$i++) {
    
Show_Itself_And_Call_Children($row["number"],$indent+1);
    }
}
?>
</body>
</html>