Hello eveybody,

I am currently creating a forum system and have gone completely blank as how to fix this issue!

The issue is as follows:

A topic is created. A user comes along and comments on the topic and message is posted on the thread. Right!

Now another user comes along and views the topic and sees that there is a comment left by a user. So, user decides to reply to this comment not directly related to the topic and clicks on 'reply now'.

Anyways onces the types in the message to this comment he clicks on the button 'reply now'.

So, now when the message is posted on the thread, there are two messages, both from a different user.

My plan is to put the old message into a box or quote box and have the old message below which I am unable to acheive.

My code for posting this message is as follows:

echo "<form method=\"post\" action=\"./index.php?act=test&id=".$row['tid']."&reply_id=".$reply_id."\">\n";
		 echo "<table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">\n";
echo "<tr><td colspan=\"2\" align=\"center\"><textarea style=\"width:90%;height:200px\" name=\"reply\"></textarea><br><input type=\"submit\" name=\"submit\" value=\"Add Reply\" stlye=\"width:90%\"></td></tr>\n";
         echo "</table>\n";
		 echo "</table>\n";

$row stores the old message. This message is just in plan text but I would like to have this message in a

box once posted.

like below


example

Thanks

Are you using 'bbcode' or something similar to allow the users to add their messages? This would be one of the simplest ways to do it.

My example here uses 'bbcode', the PHP for quotes is this:

<?php
   function bbcode($Text)
       {
            // Check for Quotes
            $numquotes=substr_count($Text, "[quote=");
            for ($i = 0; ($i < $numquotes); $i++)
            {
            $Text = preg_replace("/\[quote\=(.+?)](.+?)\[\/quote\]/s",'<span class="quotebody">$1 Said:<br />$2</span>',$Text);
            }
      }
?>

This is not the whole bbcode script, just the bit that checks for [quote=name] tags
CSS:

.quotebody {
   background-color: #ffffaa;
   font-family: Verdana, Tahoma;
   font-size: 1em;
   color: #660002;
   border: 1px solid #000000;
   margin-left: 5px;
   display: block;
}

And the part of the script that calls the bbcode function:

<?
        echo "<td width=\"80%\" class=\"singlepost\" valign=\"top\">
                ".bbcode(htmlspecialchars($req_post['text']))."</td>";
?>

Again, not a complete script, just a snippet.

Using the above, a user who enters this:

This is a test
[quote=test]
test
[quote=test]
test
[quote=test]
test
[quote=test]
test
[/quote]
[/quote]
[/quote]
[/quote]

Would get something similar to what is shown in the attached image

Hopefully this will give you some idea of what to do.

Bro first of all thank you very much for the example?

I am actually not using BBCode in my forum as I am still learning PHP and my forum is basic.

Let me work around with your example and I'll keep you updated.

Cheers

'xan'

I understand your bbcode function, & ccs style and your script......

but is it not possible for this script

<?
        echo "<td width=\"80%\" class=\"singlepost\" valign=\"top\">
		        ".bbcode(htmlspecialchars($req_post['text']))."</td>";
?>

to implement it in my code like this:

<?php
 echo "<form method=\"post\" action=\"./index.php?act=test&id=".$row['tid']."&reply_id=".$reply_id."\">\n";
		 echo "<table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">\n";
echo "<tr><td colspan=\"2\" align=\"center\"><textarea style=\"width:90%;height:200px\" name=\"reply\">".bbcode(htmlspecialchars($req_post['text']))."</textarea><br><input type=\"submit\" name=\"submit\" value=\"Add Reply\" stlye=\"width:90%\"></td></tr>\n";
         echo "</table>\n";
		 echo "</table>\n";
?>

Anybody who could help me out? Please!

I am not asking for answers but something that is easy and I could implement it easily into my code....As I am less experienced in PHP.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.