Zend - The PHP Company




Forums

Add Code


RIDWANK-DISCUSS  

Type: application
Added by: ridwank_zend
Entered: 28/05/2002
Last modified: 06/12/2001
Rating: - (fewer than 3 votes)
Views: 10785
This program need only one single page to display and post the message, other features are : - Unlimited Threading, - HTML tag Parsing, - Database Admin, - Record Paging, - Highlight current message, - Upthreaded Link, Error Checking for Uncompletly Entry, and much more.


<!-- ************************************************************************* -->
<!-- [1] FILE NAME : diskusi_config.php, THIS IS CONFIGURATION FILE -->
<!-- ************************************************************************* -->

<?php 
// *** DATABASE CONFIGURATION

$db_serv="localhost";
$db_dbas="dbas";
$db_user="user";
$db_pass="pass";

$conn=mysql_connect($db_serv,$db_user,$db_pass) or die ("can't connect to server");
@
mysql_select_db($db_dbas) or die ("can't select database");

?>
<style><!--
body         { font-family: verdana; font-size: 8pt; color: #000000 }
TD {font-family:verdana; font-size:8pt; color:#000000}

a:link {color:#283AA0; text-decoration: none}
a:active {color:#283AA0; text-decoration: none }
a:visited {color:#283AA0; text-decoration: none }
a:hover {color:#283AA0; text-decoration: underline }

.ttl            { font-family: Arial; font-size: 14pt; color: #FFFFFF; font-weight: bold; 
               background-color: #808080 }
.entri {background-color: #E9E8E8; font-family: verdana; font-size: 8pt; border: 1 inset #E9E8E8}
.tombol {background-color: #C0C0C0; font-family: verdana; font-size: 8pt; color:#283AA0; font-weight: bold; border: 1 solid #808080; cursor:hand}
--></style>
<!-- YOU CAN DELETE THIS HTML BELOW, IT'S USE ONLY TO LINK THE FILE -->
<table border=0 width=100% cellspacing=1 bgcolor=#000000><tr><td align=center bgcolor=#CCCCCC><b>
[<a href="diskusi.php">Discussion Board</a>] &#149 [<a href="adm_diskusi.php">Admin</a>]
</td></tr></table>

<!-- ************************************************************************* -->
<!-- [2] FILE NAME : diskusi.php, THIS IS FORUM - MAIN PAGE -->
<!-- ************************************************************************* -->

<?php include "diskusi_config.php"?>

<p class=ttl>&nbsp;&#149 Discussion Board</p>

<table border=0 width=100% cellspacing=10 cellpadding=0><tr><td>
<?php

$topic
=@mysql_query("select * from diskusi_topic order by nama");
$ada=@mysql_num_rows($topic);
if (
$ada>0){
   echo 
"<table border=0 cellspacing=4 cellpadding=0 width=100%>";
   while (
$r=@mysql_fetch_array($topic)){
      echo 
"<tr><td><font style='font-size:14pt'>";
      echo 
"<a href='diskusi_view.php?topic_id=".$r[id]."'>".$r[nama]."</a></font><br>";
      echo 
nl2br($r[keterangan]);
      
$jmlmsg=@mysql_num_rows(@mysql_query("select id from diskusi where topic='$r[id]'"));
      echo 
"<br>(Jumlah : ".number_format($jmlmsg)." messages)";
      echo 
"<div align=right><a href='diskusi_view.php?topic_id=".$r[id]."'><b>[ENTER]</b></a></div>";
      echo 
"</td></tr>";
      echo 
"<tr><td background='images/line_hor.gif'><img src='images/line_hor.gif' border=0 width=4 height=1></td></tr>";
   }
   echo 
"</table>";
} else {
   echo 
"<p>BELUM ADA TOPIC DISKUSI</p>";

}


?>
</td></tr>
</table>

<!-- ************************************************************************* -->
<!-- [3] FILE NAME : diskusi_view.php, THIS IS FORUM - FOR VIEWING & POSTING MESSAGE -->
<!-- ************************************************************************* -->


<?php include "diskusi_config.php"?>

<p class=ttl>&nbsp;&#149 Discussion Board</p>

<table border=0 width=100% cellspacing=10 cellpadding=0><tr><td>

<script language="javascript">
<!--
function cek(form)
{ with (form)
  {
    if (msg_judul.value.length==0)
    { alert("Please fill Subject");
      msg_judul.focus();
      return false;
    }
    if (msg_message.value.length==0)
    { alert("Please fill your Message");
      msg_message.focus();
      return false;
    }
    if (msg_nama.value.length==0)
    { alert("Please fill your name");
      msg_nama.focus();
      return false;
    }
    if (msg_email.value.length==0)
    { alert("Please fill your email");
      msg_email.focus();
      return false;
    }
  }
  return;
}
//-->
</script>

<?php

function anak($p_id,$jm,$tdcol){
   global 
$topic_id;
   
$rs2=@mysql_query("select * from diskusi where parent_id='$p_id' and topic='$topic_id'");
   
$ada=@mysql_num_rows($rs2);
   if (
$ada>0){
      
$jm++;
      while (
$r2=@mysql_fetch_array($rs2)){
         
$sp="";
         for (
$i=1;$i<=$jm-1;$i++){
            
$sp.="<img src='blank.gif' border=0 width=14 height=10>";
         }
         echo 
"<tr>";
         echo 
"<td bgcolor='".$tdcol."' valign=top>";
            if (
$jm<=6){
               
$bljm=$jm;
            } else {
               
$bljm=($jm 6);
            }
            echo 
"<table border=0 cellspacing=0 cellpadding=0><tr><td valign=top>";
            echo 
$sp."<img src='bullet_".$bljm.".gif' border=0 width=10 height=10>";
            echo 
"</td><td valign=top>";
            echo 
"<b><a href='".$PHP_SELF."?message_id=".$r2[id]."&topic_id=".$topic_id."'>".$r2[judul]."</a>";
            echo 
"</td></tr></table>";
         echo 
"</td>";
         echo 
"<td bgcolor='".$tdcol."' valign=top>".$r2[nama]."</td>";
         echo 
"<td bgcolor='".$tdcol."' valign=top nowrap>".date('j M Y',$r2[tanggal])."</td>";
         echo 
"</tr>";
         
anak($r2[id],$jm,$tdcol);
      }

   }

}

echo 
"<div><b><a href='diskusi.php'>TOPIC</a>&nbsp;<font style='font-size:12pt'>�</font>&nbsp;";
$topic_name=@mysql_result(@mysql_query("select nama from diskusi_topic where id='$topic_id'"),0,0);
$topic_name=strtoupper($topic_name);
echo 
"<a href='diskusi_view.php?topic_id=".$topic_id."'>".$topic_name."</a></b></div>";
echo 
"<div align=right><b>[<a href='".$PHP_SELF."?reply_id=x&topic_id=".$topic_id."'>Post New Message</a>]</b></div><br>";

if (
$msg_submit=="KIRIM"){
   
$now=time();
   
$qinsert="insert into diskusi (tanggal,judul,message,nama,email,parent_id,topic) ";
   
$qinsert.="values ('$now','$msg_judul','$msg_message','$msg_nama','$msg_email','$msg_parent_id','$topic_id')";
   @
mysql_query($qinsert);
   
$message_id=@mysql_result(@mysql_query("select id from diskusi where topic='$topic_id' order by id desc limit 0,1"),0,0);

      
// *** ADDING TO NEWSLETTER *** //
      
$sudahada=@mysql_num_rows(@mysql_query("select email from one_listener where email='$msg_email' and jenis_member='Newsletter'"));
      if (
$sudahada==0){
         @
mysql_query("insert into one_listener (nama,email,jenis_member) values ('$msg_nama','$msg_email','Newsletter')");
      }

}

if (!empty(
$reply_id)){
   echo 
"<table width=100% border=0 cellspacing=1 cellpadding=10 bgcolor=#000000><tr><td bgcolor=#F7F7FF>";
   echo 
"<form action='".$PHP_SELF."' method='post' onSubmit='return cek(this)'>";
   echo 
"<br>Subject : ";
   if (
$reply_id<>"x"){
      
$reply_subject=@mysql_result(@mysql_query("select judul from diskusi where id='$reply_id'"),0,0);
      
$reply_subject="RE: ".$reply_subject;
      
$reply_message=@mysql_result(@mysql_query("select message from diskusi where id='$reply_id'"),0,0);
      
$reply_message=str_replace("n","&gt",$reply_message);
      
$reply_message="nnn============================n".$reply_message;
      echo 
"<input type='hidden' name='msg_parent_id' value='".$reply_id."'>";
   } else {
      echo 
"<input type='hidden' name='msg_parent_id' value='0'>";
   }
   echo 
"<input type='hidden' name='topic_id' value='".$topic_id."'>";
   echo 
"<br><input name='msg_judul' size=50 class=entri value='".$reply_subject."'>";
   echo 
"<br>Messages : ";
   echo 
"<br><textarea name='msg_message' rows=5 cols=50 class=entri>".$reply_message."</textarea>";
   echo 
"<br>Name : ";
   echo 
"<br><input name='msg_nama' class=entri>";
   echo 
"<br>Email : ";
   echo 
"<br><input name='msg_email' class=entri>";
   echo 
"<br><br><input type='submit' name='msg_submit' class=tombol value='KIRIM'>";
   echo 
"&nbsp<input type='reset' name='msg_reset' class=tombol value='RESET'>";
   echo 
"</form>";
   echo 
"</td></tr></table><br>";

}

if (!empty(
$message_id)){
   
$msg_dtl=@mysql_query("select * from diskusi where id='$message_id' and topic='$topic_id'");
   
$adamsg=@mysql_num_rows($msg_dtl);
   if (
$adamsg>0){

   
$id=@mysql_result($msg_dtl,0,"id");
   
$tanggal=@mysql_result($msg_dtl,0,"tanggal");
   
$judul=@mysql_result($msg_dtl,0,"judul");
   
$message=@mysql_result($msg_dtl,0,"message");
   
$nama=@mysql_result($msg_dtl,0,"nama");
   
$email=@mysql_result($msg_dtl,0,"email");
   
$parent_id=@mysql_result($msg_dtl,0,"parent_id");

   echo 
"<table width=100% border=0 cellspacing=1 cellpadding=2 bgcolor=#000000><tr><td bgcolor=#F7F7FF>";
   echo 
date('j M Y - H:i',$tanggal);
   echo 
"<br><b><a href='mailto:".$email."'>".$nama."</a></b>";
   echo 
"<hr noshade size=1 color=#000000>";
   echo 
"<u>".$judul."</u>";
   echo 
"<br><br>".nl2br($message);
   echo 
"<hr noshade size=1 color=#000000>";
   echo 
"<div align=right><b>";
   if (
$parent_id<>0){
      echo 
"[<a href='".$PHP_SELF."?message_id=".$parent_id."&topic_id=".$topic_id."'>Up Thread</a>]&nbsp";
   }
   echo 
"[<a href='".$PHP_SELF."?reply_id=".$id."&topic_id=".$topic_id."'>Reply This Message</a>]";
   echo 
"</b></div>";
   echo 
"</td></tr></table><br>";
   
   }

}

// *** (start) PAGING

   
if (empty($start)){
      
$start=0;
   }

   
$recperpage=10;

   
$totrec=@mysql_num_rows(@mysql_query("select id from diskusi where parent_id='0' and topic='$topic_id'"));

   if (
$totrec>$recperpage){
      
$prev=$start-$recperpage;
      
$next=$start+$recperpage;
      echo 
"<br><b>Page : </b>";
      if (!
$start==0){
         echo 
"<a href='".$PHP_SELF."?start=".$prev."&topic_id=".$topic_id."' class=navart>�</a>&nbsp";
      } else {
         echo 
"<b>�</b>&nbsp";
      }
      echo 
"<b>";
      for (
$i=1$i<=ceil($totrec/$recperpage);$i++){
         if (((
$start/$recperpage)+1)==$i){
            echo 
"<font color=#FF0000><b>".$i."</b></font> ";
         } else {
            
$startval=($i-1)*$recperpage;
            echo 
"<a href='".$PHP_SELF."?start=".$startval."&topic_id=".$topic_id."' class=navart>".$i."</a> ";
         }
      }
      echo 
"</b>";
      if (
$start<($totrec-$recperpage)){
         echo 
"<a href='".$PHP_SELF."?start=".$next."&topic_id=".$topic_id."' class=navart>�</a>";
      } else {
         echo 
"<b>�</b>";
      }
      echo 
"<br>";
   }

// *** (end) PAGING

$rs=@mysql_query("select id,tanggal,judul,nama,email,parent_id from diskusi where parent_id='0' and topic='$topic_id' order by tanggal desc limit $start,$recperpage");
$ada=@mysql_num_rows($rs);
if (
$ada>0){
      echo 
"<table width=100% border=0 cellspacing=1 cellpadding=2 bgcolor=#000000>";
      echo 
"<tr>";
      echo 
"<td bgcolor=#3996C6><font color=#FFFFFF><b>Subject</td>";
      echo 
"<td bgcolor=#3996C6><font color=#FFFFFF><b>Sender</td>";
      echo 
"<td bgcolor=#3996C6><font color=#FFFFFF><b>Postdate</td>";
      echo 
"</tr>";
   while (
$r=@mysql_fetch_array($rs)){
      
$baris++;
      if ((
$baris 2)==0){
         
$tdcol="#FFFFFF";
      }  else {
         
$tdcol="#E7F3FF";
      }
      echo 
"<tr>";
      echo 
"<td bgcolor='".$tdcol."' valign=top><b><a href='".$PHP_SELF."?message_id=".$r[id]."&topic_id=".$topic_id."'>".$r[judul]."</a></td>";
      echo 
"<td bgcolor='".$tdcol."' valign=top>".$r[nama]."</td>";
      echo 
"<td bgcolor='".$tdcol."' valign=top>".date('j M Y',$r[tanggal])."</td>";
      echo 
"</tr>";
      
anak($r[id],0,$tdcol);   
   }
      echo 
"</table>";
} else {
   echo 
"<p>Messages Board untuk TOPIC : ".$topic_name." belum ada.</p>";
}


?>
</td></tr>
</table>

<!-- ************************************************************************* -->
<!-- [4] FILE NAME : adm_diskusi.php, THIS IS FORUM DATABASE ADMINISTRATION  -->
<!-- ************************************************************************* -->

<?php 
include "diskusi_config.php";

echo 
"<p class=ttl>&nbsp;&#149 Admin Discussion Board</p>";

if (empty(
$topic_id)){
   
$topic_id="%%";
}

echo 
"Pilih Topic : <select class='entri' onChange="window.location this.options[this.selectedIndex].value">";
echo 
"<option value='".$PHP_SELF."?topic_id=%%'";
   if (
$topic_id=="%%"){
      echo 
" selected";
   }
echo 
">- SEMUA TOPIC -</option>";
$rshow2=@mysql_query("select id,nama from diskusi_topic order by nama");
while(
$r=@mysql_fetch_array($rshow2)){
   echo 
"<option value='".$PHP_SELF."?topic_id=".$r[id]."'";
   if (
$r[id]==$topic_id){
      echo 
" selected";
   }
   echo 
">";
   echo 
$r[nama];
   echo 
"</option>";
}
echo 
"</select>&nbsp<a href='adm_diskusi_topic.php'>[Modify Topic]</a><br>";


// *** (start) PAGING

   
if (empty($start)){
      
$start=0;
   }

   
$recperpage=10;

   
$totrec=@mysql_num_rows(@mysql_query("select id from diskusi where topic like '$topic_id'"));

   if (
$totrec>$recperpage){
      
$prev=$start-$recperpage;
      
$next=$start+$recperpage;
      echo 
"<b>Page : </b>";
      if (!
$start==0){
         echo 
"<a href='".$PHP_SELF."?start=".$prev."&topic_id=".$topic_id."' class=navart>�</a>&nbsp";
      } else {
         echo 
"<b>�</b>&nbsp";
      }
      for (
$i=1$i<=ceil($totrec/$recperpage);$i++){
         if (((
$start/$recperpage)+1)==$i){
            echo 
"<b>".$i."</b> ";
         } else {
            
$startval=($i-1)*$recperpage;
            echo 
"<a href='".$PHP_SELF."?start=".$startval."&topic_id=".$topic_id."' class=navart>".$i."</a> ";
         }
      }
      if (
$start<($totrec-$recperpage)){
         echo 
"<a href='".$PHP_SELF."?start=".$next."&topic_id=".$topic_id."' class=navart>�</a>";
      } else {
         echo 
"<b>�</b>";
      }
   }

// *** (end) PAGING


   
$t=@mysql_query("select id,tanggal,judul,nama,topic from diskusi where topic like '$topic_id' order by tanggal desc limit $start,$recperpage");
   
$ada=@mysql_num_rows($t);
if (
$ada>0){
   echo 
"<table border=0 cellspacing=0 cellpadding=0 width=100%>";
   while (
$r=@mysql_fetch_array($t)){
      echo 
"<tr><td colspan=4 background='line_hor.gif'><img src='line_hor.gif' border=0 width=4 height=1></td></tr>";
      
$topic_name=@mysql_result(@mysql_query("select nama from diskusi_topic where id='$r[topic]'"),0,0);
      echo 
"<tr><td>".$topic_name."</td>";
      echo 
"<td>".date('j M Y - H:i',$r[tanggal])."</td>";
      echo 
"<td>".$r[judul]."</td>";
      echo 
"<td>".$r[nama]."</td>";
      echo 
"<td><a href='adm_diskusi_mod.php?id=".$r[id]."'>Modify</a></td></tr>";
   }
   echo 
"</table>";
} else {
   echo 
"<p>database is empty</p>";
}

?>

<!-- ************************************************************************* -->
<!-- [5] FILE NAME : adm_diskusi_mod.php, THIS IS FORUM DATABASE ADMINISTRATION FOR MODIFY MESSAGE RECORD -->
<!-- ************************************************************************* -->

<?php 
include "diskusi_config.php";

if (
$btdelete=="DELETE"){
   
$qdelete.="delete from diskusi where id='$id'";
   
mysql_query($qdelete);
}

if (
$btedit=="EDIT"){
   
$tanggal=mktime($jam,$mnt,0,$bln,$tgl,$thn);
   
$qedit.="update diskusi set ";
   
$qedit.="tanggal='$tanggal',";
   
$qedit.="judul='$judul',";
   
$qedit.="message='$message',";
   
$qedit.="nama='$nama',";
   
$qedit.="email='$email' ";
   
$qedit.="where id='$id'";
   
mysql_query($qedit);
}

echo 
"<p class=ttl>&nbsp;&#149 Admin Discussion Board : MODIFY</p>";

if (!empty(
$id)){
  
$rsdtl=@mysql_query("select * from diskusi where id='$id'");
  
$ada=@mysql_num_rows($rsdtl);
  if (
$ada>0){
  
// *** (if exist) *** //
      
$id=@mysql_result($rsdtl,0,"id");
      
$tanggal=@mysql_result($rsdtl,0,"tanggal");
      
$judul=@mysql_result($rsdtl,0,"judul");
      
$message=@mysql_result($rsdtl,0,"message");
      
$nama=@mysql_result($rsdtl,0,"nama");
      
$email=@mysql_result($rsdtl,0,"email");

      echo 
"<form action='".$PHP_SELF."' method='post'>";
      echo 
"<table>";
      echo 
"<tr><td align=right valign=top>Postdate : </td><td>";
      echo 
"<select name='tgl' class=entri>";
      for (
$i=1;$i<=31;$i++){
         echo 
"<option";
         if (
$i==date('j',$tanggal)){
            echo 
" selected";
         }
         echo 
">".$i;
         echo 
"</option>";
      }
      echo 
"</select>";
      echo 
"<select name='bln' class=entri>";
      
$arrbln=array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
      for (
$i=1;$i<=12;$i++){
         echo 
"<option value='".$i."'";
         if (
$i==date('n',$tanggal)){
            echo 
" selected";
         }
         echo 
">".$arrbln[$i];
         echo 
"</option>";
      }
      echo 
"</select>";
      echo 
"<select name='thn' class=entri>";
      for (
$i=1999;$i<=2010;$i++){
         echo 
"<option";
         if (
$i==date('Y',$tanggal)){
            echo 
" selected";
         }
         echo 
">".$i;
         echo 
"</option>";
      }
      echo 
"</select> - ";
      echo 
"<select name='jam' class=entri>";
      for (
$i=0;$i<=23;$i++){
         echo 
"<option";
         if (
$i==date('H',$tanggal)){
            echo 
" selected";
         }
         echo 
">".sprintf("%02d",$i);
         echo 
"</option>";
      }
      echo 
"</select>:";
      echo 
"<select name='mnt' class=entri>";
      for (
$i=0;$i<=60;$i++){
         echo 
"<option";
         if (
$i==date('i',$tanggal)){
            echo 
" selected";
         }
         echo 
">".sprintf("%02d",$i);
         echo 
"</option>";
      }
      echo 
"</select>";
      echo 
"</td></tr>";

      echo 
"<tr><td align=right valign=top>Subject : </td><td><input name='judul' size=40 value='".$judul."' class=entri></td></tr>";
      echo 
"<tr><td align=right valign=top>Message : </td><td><textarea name='message' cols=40 rows=6 class=entri>".$message."</textarea></td></tr>";
      echo 
"<tr><td align=right valign=top>Nama : </td><td><input name='nama' value='".$nama."' class=entri></td></tr>";
      echo 
"<tr><td align=right valign=top>Email : </td><td><input name='email' value='".$email."' class=entri></td></tr>";
      echo 
"<tr><td colspan=2 align=center bgcolor=#CCEDFF>";
      echo 
"<input type='hidden' name='id' value='".$id."'>";
      echo 
"<input type='submit' name='btedit' value='EDIT' class=tombol>";
      echo 
"&nbsp;<input type='button' name='btdelete' value='DELETE' onclick='window.location = "adm_diskusi_mod.php?btdelete=DELETE&id=".$id.""' class=tombol>";
      echo 
"&nbsp;<input type='button' name='btcancel' value='BACK' onclick='window.location = "adm_diskusi.php"' class=tombol>";
      echo 
"</td></tr>";
      echo 
"</table>";
      echo 
"</form>";
      if (
$btedit=="EDIT"){
         echo 
"<h2>One record has been updated!</h2>";
      }
   } else {
   
// *** (if not exist = DELETED) *** //
      
echo "<h2>One Message Board deleted!</h2>";
      echo 
"<input type='button' name='btcancel' value='BACK' onclick='window.location = "adm_diskusi.php"' class=tombol>";
   }
} else {
   echo 
"<p>Please select item to Modify!";
}

if (!empty(
$error_teks)){
   
errormessage($error_teks);
}
?>

<!-- ************************************************************************* -->
<!-- [6] FILE NAME : adm_diskusi_topic.php, THIS IS FORUM DATABASE ADMINISTRATION FOR : ADDING, EDITING & DELETING FORUM TOPICS -->
<!-- ************************************************************************* -->

<?php 
include "diskusi_config.php";

echo 
"<p class=ttl>&nbsp;&#149 Admin Discussion Board (Modify Topic)</p>";

$act_rsl="";

if (
$btadd=="ADD"){
   @
mysql_query("INSERT INTO diskusi_topic (nama, keterangan) VALUES ('$fnama', '$fketerangan')");
   
$act_rsl="ONE TOPIC HAS BEEN ADDED";
}

if (
$btedit=="EDIT"){
   @
mysql_query("update diskusi_topic set nama='$fnama', keterangan='$fketerangan' where id='$topic_id'");
   
$act_rsl="ONE TOPIC HAS BEEN EDITED";
}

if (
$btdelete=="DELETE"){
   @
mysql_query("delete from diskusi_topic where id='$topic_id'");
   @
mysql_query("delete from diskusi where topic='$topic_id'");
   
$act_rsl="ONE TOPIC HAS BEEN DELETED, <br>AND ALL MESSAGES IN THIS TOPIC HAS BEEN DELETED TOO";
}



echo 
"<p><a href='adm_diskusi.php'>Back to Admin Discussion Board</a>";
echo 
"&nbsp;&#149;&nbsp;<a href='".$PHP_SELF."'>Add New Topic</a></p>";
$topic=@mysql_query("select * from diskusi_topic order by nama");
$ada=@mysql_num_rows($topic);
if (
$ada>0){
   echo 
"<table border=0 cellspacing=4 cellpadding=0 width=100%>";
   echo 
"<tr><td background='line_hor.gif'><img src='line_hor.gif' border=0 width=4 height=1></td></tr>";
   while (
$r=@mysql_fetch_array($topic)){
      if (
$topic_id==$r[id]){
         echo 
"<form action='".$PHP_SELF."' method='post'>";
         echo 
"<tr><td bgcolor=#CCEDFF>";
         echo 
"Name:<br><input name='fnama' value='".$r[nama]."' size=40 class=entri><br>";
         echo 
"Description:<br><textarea cols=40 rows=5 name='fketerangan' class=entri>".$r[keterangan]."</textarea><br>";
         
$jmlmsg=@mysql_num_rows(@mysql_query("select id from diskusi where topic='$r[id]'"));
         echo 
"(Total : ".number_format($jmlmsg)." messages)";
         echo 
"</td></tr>";
         echo 
"<tr><td align=center bgcolor=#CCEDFF>";
         echo 
"<input type='hidden' name='topic_id' value='".$r[id]."'>";
         echo 
"<input type='submit' name='btedit' value='EDIT' class=tombol>";
         echo 
"&nbsp;<input type='submit' name='btdelete' value='DELETE' class=tombol>";
         echo 
"&nbsp;<input type='button' name='btcancel' value='BACK' onclick='window.location = "".$PHP_SELF.""' class=tombol>";
         echo 
"<br><font color=#FF0000><i><b>WARNING!!!</b><br>Deleting this topic<br>will delete all message in this topic</i></font>";
         echo 
"</td></tr>";
         echo 
"</form>";
         echo 
"<tr><td background='line_hor.gif'><img src='line_hor.gif' border=0 width=4 height=1></td></tr>";
      } else {
         echo 
"<tr><td>";
         echo 
"<b>".$r[nama]."</b><br>";
         echo 
nl2br($r[keterangan]);
         
$jmlmsg=@mysql_num_rows(@mysql_query("select id from diskusi where topic='$r[id]'"));
         echo 
"<br>(Total : ".number_format($jmlmsg)." messages)";
         echo 
"<div align=right><a href='".$PHP_SELF."?topic_id=".$r[id]."'><b>[MODIFY]</b></a></div>";
         echo 
"</td></tr>";
         echo 
"<tr><td background='line_hor.gif'><img src='line_hor.gif' border=0 width=4 height=1></td></tr>";
      }
   }
   echo 
"</table>";
}

if (empty(
$topic_id)){
   echo 
"<b>ADD NEW TOPIC</b><br>";
   echo 
"<table border=0 cellspacing=4 cellpadding=0 width=100%>";
   echo 
"<form action='".$PHP_SELF."' method='post'>";
   echo 
"<tr><td background='line_hor.gif'><img src='line_hor.gif' border=0 width=4 height=1></td></tr>";
   echo 
"<tr><td bgcolor=#CCEDFF>";
   echo 
"Name:<br><input name='fnama' size=40 class=entri><br>";
   echo 
"Description:<br><textarea cols=40 rows=5 name='fketerangan' class=entri></textarea>";
   echo 
"</td></tr>";
   echo 
"<tr><td align=center bgcolor=#CCEDFF>";
   echo 
"<input type='submit' name='btadd' value='ADD' class=tombol>";
   echo 
"&nbsp;<input type='reset' name='btreset' value='RESET' class=tombol>";
   echo 
"</td></tr>";
   echo 
"</form>";
   echo 
"<tr><td background='line_hor.gif'><img src='line_hor.gif' border=0 width=4 height=1></td></tr>";
   echo 
"</table>";
}

if (!empty(
$act_rsl)){
   echo 
"<h3 align=center>".$act_rsl."</h3>";
}
?>


Usage Example


See the example


Rate This Script





Search



This Category All Categories