Jump to content

[php] comments and reply script


JonnySnip3r

Recommended Posts

Hey guys i have been making a comment and reply script. When the user makes a post and others reply they appear below. However when another person makes a post and a reply is made to that they mess up it has the comments at the top and the replys at the bottom. DOes anyone know how i could order these? Or is there a tutorial online. Hope someone can help.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/210145-php-comments-and-reply-script/
Share on other sites

$query = mysql_query("SELECT * FROM comments_messages WHERE message_reply_to_member_id = '$my_id'");

						while($row = mysql_fetch_assoc($query)){
							$message_id = $row['message_id'];
							$message_reply_to_id = $row['message_reply_to_member_id'];
							$message_from_member_id = $row['message_from_member_id'];
							$message_title = $row['message_title'];
							$message_contents = $row['message_contents'];
							$message_time_date = $row['message_time_date'];
							$member_image = $row['member_image'];
							$message_reported = $row['message_reported'];


							echo "<div class='commentHome'>";

							echo "<img src='profile/images/$member_image' alt='member profile picture' />";

							echo "<h3>$message_title <small><i>$message_time_date</i> (from: <strong>". 
							get_member_name_from_member_id($message_from_member_id) ."</strong> )</small></h3>";

							echo "<p>". rec_message_bad_word_filter($message_contents) ."</p>";


							echo "<div id='box'>";
								echo "<br />";
								echo "<form method='post' action=''>";
										echo "<input type='text' name='comment' placeholder='quick reply...'
											onclick=\"$.jGrowl('Enter your reply to this message. e.g: Hey, Dude!', 
											{ header: 'Reply Field' });\" href=\"javascript:void(0);\"/>";
										echo "<input type='hidden' name='member_id_to' value='$message_from_member_id'/>";
										echo "<input type='hidden' name='title' value='$message_title'/>";
									echo "</form>";
								echo "</div>";
						echo "</div>";

						}		

						$query = mysql_query("SELECT * FROM comments_messages WHERE message_from_member_id = '$my_id'");

						while($row = mysql_fetch_assoc($query)){
							$message_id = $row['message_id'];
							$message_reply_to_id = $row['message_reply_to_member_id'];
							$message_from_member_id = $row['message_from_member_id'];
							$message_title = $row['message_title'];
							$message_contents = $row['message_contents'];
							$message_time_date = $row['message_time_date'];
							$member_image = $row['member_image'];
							$message_reported = $row['message_reported'];
							$message_reported_to = $row['message_reported_to];

							echo "<div class='commentHome2'>";

							echo "<img src='profile/images/$member_image' alt='member profile picture' />";

							echo "<h3>$message_title <small><i>$message_time_date</i> (from: me)</small></h3>";

							echo "<p>". rec_message_bad_word_filter($message_contents) ."</p>";

								echo "<p class='rec_by'>";

									/* echo "<a href=\"#\" id=\"$message_id\" class=\"delbutton\">
									<img src='profile/icons/delete.png' alt='delete' title='Delete this Comment' /></a>";*/

									echo "</p>";
						echo "</div>";

						}

 

I know its messy and theres tons of tidying up to do :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.