rEhSi_123 Posted March 25, 2009 Share Posted March 25, 2009 Hello everybody, dont know if the above title is appropriate for my query.... But here it goes.... I created a .php files for replying to a comment. Now I am able to get the previous message on my text box in which I will reply but I want the message in quotes.......like below: hello world! I know everybody will say to install or create bbcodes but I am only creating a basic forum so not going fancy.... here is my code: <?php if(!$_SESSION['uid']){ header("Location: index.php"); } $msg = mss($_POST['reply']); $tid = mss($_GET['id']); $reply_id = $_GET['reply_id']; $id = $_GET['id']; if($tid){ echo $reply_id; $sql = "SELECT * FROM `forum_topics` WHERE `id`='".$tid."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "This topic does not exist!"; }else { $sql = "SELECT * FROM `forum_replies` WHERE `id`='".$reply_id."'"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($res); if(!$_POST['submit']){ 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\">[quote]".$row['message']."[/quote]</textarea><br><input type=\"submit\" name=\"submit\" value=\"Add Reply\" stlye=\"width:90%\"></td></tr>\n"; echo "</table>\n"; }else{ if($row2['admin'] == 1 && $admin_user_level == 0){ echo "You do not have sufficient priveleges to add a reply to this topic"; }else { if(!$msg){ echo "You did not supply a reply"; }else { if(strlen($msg) < 10 || strlen($msg) > 10000){ echo "Your reply must be between 10 and 10,000 characters!"; }else { $date = date("d-m-y") ." at ". date("h-i-s"); $time = time(); $sql4 = "INSERT INTO `forum_replies` (`tid`,`uid`,`message`,`date`,`time`,`reply_id`) VALUES('".$tid."','".$_SESSION['uid']."','".$msg."','".$date."','".$time."','".$reply_id."')"; $res4 = mysql_query($sql4) or die(mysql_error()); header("Location: ./index.php?act=topic&id=".$tid); } } } } } } ?> So therefore I just want the $row['message'] part in quotes once I click on 'reply' Thanks Quote Link to comment Share on other sites More sharing options...
rEhSi_123 Posted March 25, 2009 Author Share Posted March 25, 2009 Sorry made a mistake....appologies Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 25, 2009 Share Posted March 25, 2009 <?php echo "<tr><td colspan=\"2\" align=\"center\"><textarea style=\"width:90%;height:200px\" name=\"reply\">[quote]\"".$row['message']."\"[/quote]</textarea><br><input type=\"submit\" name=\"submit\" value=\"Add Reply\" stlye=\"width:90%\"></td></tr>\n"; ?> Quote Link to comment Share on other sites More sharing options...
rEhSi_123 Posted March 25, 2009 Author Share Posted March 25, 2009 <?php echo "<tr><td colspan=\"2\" align=\"center\"><textarea style=\"width:90%;height:200px\" name=\"reply\">[quote]\"".$row['message']."\"[/quote]</textarea><br><input type=\"submit\" name=\"submit\" value=\"Add Reply\" stlye=\"width:90%\"></td></tr>\n"; ?> Thanks for the reply man.....but the above didn't work its displaying message like this: "Hello" how are you? Quote Link to comment Share on other sites More sharing options...
trq Posted March 25, 2009 Share Posted March 25, 2009 Where is your code for displaying this data? Quote Link to comment Share on other sites More sharing options...
rEhSi_123 Posted March 25, 2009 Author Share Posted March 25, 2009 Where is your code for displaying this data? <?php error_reporting(E_ALL ^ E_NOTICE); //Report all error except NOTICES $id = mss($_GET['id']); $page = (!$_GET['page'] || $_GET['page'] < 0) ? "1" : $_GET['page']; $page = ceil($page); $limit = 10; $start = $limit; $end = $page*$limit-($limit); if($id){ $sql = "SELECT * FROM `forum_topics` WHERE `id`='".$id."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "This topic does not exists!"; }else { $row = mysql_fetch_assoc($res); $sql2 = "SELECT admin FROM `forum_sub_cats` WHERE `id`='".$row['cid']."'"; $res2 = mysql_query($sql2) or die(mysql_error()); $row2 = mysql_fetch_assoc($res2); if($row2['admin'] == 1 && $admin_user_level == 0){ echo "You cannot view this topic!"; }else { $a = (isa($row['uid'])) ? "<font style=\"color:#800000;\">ADMIN</font>" : ""; echo "<table border=\"0\" width=\"100%\"cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<tr><td colspan=\"2\" align=\"left\" class=\"forum_header\"><b>".$row['title']."</b>- Posted on: <em>".$row['date']."</em></td></tr>\n"; echo "<tr><td align=\"left\" width=\"15%\" valign=\"top\" class=\"forum_header\">".uid($row['uid'],true)."<br>Post Count: ".post($row['uid'])."</br>".$a."</td>\n"; echo "<td align=\"left\" valign=\"top\" class=\"forum_header\">\n"; echo topic($row['message']); echo "</td>\n"; echo "</tr>\n"; $amount_check = "SELECT * FROM `forum_replies` WHERE `tid`='".$id."'"; $amount_check_res = mysql_query($amount_check) or die(mysql_error()); $amount_count = mysql_num_rows($amount_check_res); $pages = ceil($amount_count/$limit); $previous = ($page-1 <= 0) ? "« Prev" : "<a href=\"./index.php?act=topic&id=".$id."&page=".($page-1)."\">« Prev</a>"; $nextpage = ($page+1 > $pages) ? "Next »" : "<a href=\"./index.php?act=topic&id=".$id."&page=".($page+1)."\">Next »</a>"; echo "<tr><td align=\"right\" colspan=\"2\" class=\"forum_header\">\n"; echo "Pages: "; echo $previous; for($i=1;$i<=$pages;$i++){ $href = ($page == $i) ? " ".$i." " : " <a href=\"./index.php?act=topic&id=".$id."&page=".$i."\">".$i."</a> "; echo $href; } echo $nextpage; echo "</td></tr>\n"; $select_sql = "SELECT * FROM `forum_replies` WHERE `tid`='".$id."' ORDER BY id ASC LIMIT ".$end.",".$start.""; $select_res = mysql_query($select_sql) or die(mysql_error()); while($rowr = mysql_fetch_assoc($select_res)){ echo "<tr><td colspan=\"2\" align=\"left\" class=\"forum_header\">Posted on: <em>".$rowr['date']."</em></td></tr>\n"; echo "<tr><td align=\"left\" width=\"15%\" valign=\"top\" class=\"forum_header\">".uid($rowr['uid'],true)."<br>Post Count: ".post($rowr['uid'])."</br>".$a."</td>\n"; echo "<td align=\"left\" valign=\"top\" class=\"forum_header\">\n"; echo topic($rowr['message']); if($rowr['edit_time'] > 0){ echo "<tr><td align=\"left\" colspan=\"3\" class=\"forum_header\"><em>Edited at:".date("l jS \of F Y",$rowr['edit_time']) . " at " . date("h:i:s",$rowr['edit_time'])."</em></td></tr>\n"; } $adminz = isa($_SESSION['uid']); if($adminz == 1 || $rowr['uid'] == $_SESSION['uid']){ echo "<tr><td align=\"right\" colspan=\"2\"><a href=\"index.php?act=mod&act2=reply&id=".$rowr['id']."\"><img src=\"edit.gif\"></a> <a href=\"index.php?act=mod&act2=topic&id=".$rowr['id']."\" onclick=\"return confirm('Are you sure you want to delete?')\"><img src=\"delete.gif\"></a> <a href=\"index.php?act=test&id=".$rowr['tid']."&reply_id=".$rowr['id']."\"><img src=\"quoteIcon.gif\"></a></td></tr>\n"; } echo "</td>\n"; echo "</tr>\n"; } echo "<tr><td colspan=\"2\" align=\"left\"><a href=\"./index.php?act=reply&id=".$row['id']."\">Reply Now</a></td></tr>\n"; echo "</table>\n"; } } }else { echo "Please view a valid topic!"; } ?> Quote Link to comment Share on other sites More sharing options...
rEhSi_123 Posted March 25, 2009 Author Share Posted March 25, 2009 Anybody Thanks Quote Link to comment Share on other sites More sharing options...
trq Posted March 25, 2009 Share Posted March 25, 2009 You might want to narrow your code down to the part that actually displays the message you want quotes. besides, all you need do is wrap that part within the relevent html. There really isn't such a thing a a html 'quote', so its pretty unclear what your after. Quote Link to comment Share on other sites More sharing options...
rEhSi_123 Posted March 25, 2009 Author Share Posted March 25, 2009 hello What I am after is exactly as above ^^^ So when a user replies to a user comment he/she clicks on the rply button which then displays this part of the code: if(!$_POST['submit']){ 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\">[quote]".$row['message']."[/quote]</textarea><br><input type=\"submit\" name=\"submit\" value=\"Add Reply\" stlye=\"width:90%\"></td></tr>\n"; echo "</table>\n"; The above html form also displays the previous message to which the user is replying.....OK! Therefore once the user finishes typing the message, user then click on Add Reply. This then takes the message along with the previous message back to the main thread......to which the code is present in the topic.php I posted in reply to your request. Hope you can understand what I am after So finally I want the previous message displayed in QUOTES as above along with new comment left by the user. Cheers Quote Link to comment Share on other sites More sharing options...
trq Posted March 25, 2009 Share Posted March 25, 2009 Yeah, thats kinda what I thought you where hinting at. Not as simple as that I'm afraid. This really isn't something your going to get a solution to in a simple forum post. Your probably better off looking at some open source forums to see how they do it. Theres quite a bit of work involved in getting something like that (assuming you mean something like the way this board works) working. Quote Link to comment Share on other sites More sharing options...
rEhSi_123 Posted March 25, 2009 Author Share Posted March 25, 2009 Yeah, thats kinda what I thought you where hinting at. Not as simple as that I'm afraid. This really isn't something your going to get a solution to in a simple forum post. Your probably better off looking at some open source forums to see how they do it. Theres quite a bit of work involved in getting something like that (assuming you mean something like the way this board works) working. Right Would you recommend using bbcode or something......I only want the quote thingy to work.....but since you are saying its not easy :'( Quote Link to comment Share on other sites More sharing options...
trq Posted March 25, 2009 Share Posted March 25, 2009 bbcode is just a simpler syntax to html, its not really needed. If all you want is your replies to be within a styled box, use <span> tags to put them in one. Then you can use css to style that box. this really hasn't anything to do with php. If on the other hand you want when users click the text they are quoting is placed within the textarea, that requires javascript. From there you will likely want to parse that inserted text using some form of bbcode. Quote Link to comment Share on other sites More sharing options...
rEhSi_123 Posted March 25, 2009 Author Share Posted March 25, 2009 bbcode is just a simpler syntax to html, its not really needed. If all you want is your replies to be within a styled box, use <span> tags to put them in one. Then you can use css to style that box. this really hasn't anything to do with php. If on the other hand you want when users click the text they are quoting is placed within the textarea, that requires javascript. From there you will likely want to parse that inserted text using some form of bbcode. Well I tried using span tags but it didn't seem to work....... Quote Link to comment Share on other sites More sharing options...
trq Posted March 25, 2009 Share Posted March 25, 2009 That is a html issue, not php. Quote Link to comment Share on other sites More sharing options...
rEhSi_123 Posted March 30, 2009 Author Share Posted March 30, 2009 Anybody here who could further help me solve my problem....... I am really not fussed about having quote box or want the user to input boxes, all I would like to have be a simple box around the previous message so that it distinguishes it from the new message. Please Please Advice..... Thanks Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 30, 2009 Share Posted March 30, 2009 Have PHP define the new messages in divs that have a class called new messages, then change the style of that class in CSS. Quote Link to comment Share on other sites More sharing options...
rEhSi_123 Posted April 2, 2009 Author Share Posted April 2, 2009 Bump! Anybody with further ideas....... Well if you recon if the quotebox would be complicated to acheive....will it be possible to have the reply in speech/quote marks like this: "Hello world!" Thanks Quote Link to comment Share on other sites More sharing options...
WolfRage Posted April 2, 2009 Share Posted April 2, 2009 Additionaly if the data is being pulled from the database, just prepend the string with ' " ' and then append it with ' " '. Quote Link to comment Share on other sites More sharing options...
rEhSi_123 Posted April 2, 2009 Author Share Posted April 2, 2009 Additionaly if the data is being pulled from the database, just prepend the string with ' " ' and then append it with ' " '. Sorry for being a dumb... Could please give me example?as ian still learning php. As my old message is in a array form... $row['message'] if u check my previous posts. Thanks Quote Link to comment Share on other sites More sharing options...
WolfRage Posted April 3, 2009 Share Posted April 3, 2009 <?php echo "<tr><td colspan=\"2\" align=\"center\"><textarea style=\"width:90%;height:200px\" name=\"reply\">".' " '.$row['message'].' " '."</textarea><br><input type=\"submit\" name=\"submit\" value=\"Add Reply\" stlye=\"width:90%\"></td></tr>\n"; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.