Jump to content

[SOLVED] Only one comment showing


DeanWhitehouse

Recommended Posts

I don't post here often now, but this one really has got me stuck.

This is my site, and i have added a comment system.

http://djw-webdesign.awardspace.com/comment.php?id=1

The count is not wrong there are 2 comments, but only one is shown, and when there was only one comment it didn't show it.

This is the comment.php code, i removed the add comment code to make it shorter to read.

<?php
ob_start();
include 'Includes/header.php';
include 'Includes/nav.php';
?>
</div>
<div id="wrapper">
<div id="page">
<div id="content">
<?php
if(isset($_GET['id']) && is_numeric($_GET['id']))
{
$id = $_GET['id'];
$id = stripslashes($id);
$sql = "SELECT * FROM djw_comments WHERE parent_id = ".$id." ORDER BY time DESC";
$sql = mysql_query($sql);
$nums = mysql_num_rows($sql);	
$r = mysql_fetch_assoc($sql);
$sql1 = mysql_query("SELECT * FROM djw_blog WHERE id =".$id);
$rows = mysql_fetch_assoc($sql1);
if(!$sql || !$sql1 || $id <= 0 || mysql_num_rows($sql1) == 0)
{
	header("Location:http://djw-webdesign.awardspace.com/index.php");
	exit();
}	
?>
	<div class="post">
		<h1 class="title"><a href="http://djw-webdesign.awardspace.com/blog.php#blog_id_<?php echo $rows['id']; ?>"><?php echo $rows['title'];?></a></h1>
		<p class="byline"><small>Posted on <?php echo date("F jS, Y",strtotime($rows['time'])); ?> by <a href="about.php?what=me"><?php echo $rows['poster']; ?></a></small></p>
		<div class="entry">
			<p><?php echo nl2br($rows['content']); ?></p>
		</div>
	</div>
	<div class="post">
		<h1 class="title">Comments(<?php echo $nums;?>)</h1><p class="byline"><small><a href="#comment">Comment</a></small></p>
<?php
while($row = mysql_fetch_assoc($sql))
{
?>
		<div class="entry">
		<h3><a name="id<?php echo $row['id']; ?>"></a>Posted on <?php echo date("F jS, Y",strtotime($row['time'])); ?> by <a href="Javascript:void();"><?php echo wordwrap($row['poster'],40,"<br>",true); ?></a></h3>
		<?php 
			$cont = $row['content'];
			$cont = wordwrap($cont,65,"<br>",true);
			$cont = nl2br($cont);
			$cont = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $cont);
			$cont = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $cont);
		?>
			<p><?php echo $cont; ?></p>
		</div>
<?php
}
?>
	</div>
<?php
}
else
{
header("Location:http://djw-webdesign.awardspace.com/index.php");
exit();
} 
?>
</div>
<?php
include 'Includes/sidebar.php';
include 'Includes/footer.php';
?>

Link to comment
https://forums.phpfreaks.com/topic/132613-solved-only-one-comment-showing/
Share on other sites

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.