I planned on:
Comments:<br>
<br>$posted_username
That way 2 linebreaks before the first comment then one inbetween each comment.
Printable View
I planned on:
Comments:<br>
<br>$posted_username
That way 2 linebreaks before the first comment then one inbetween each comment.
that makes more sense, but in your script, you are including the Comments:<br><br> with the while loop.
If you only want 1 Comments (which is a good idea) just print out the comments before looping the array
No, no. Sorry I explained it wrong man heres a copy of the actual script:
Thanks for all your help everyone.PHP Code:<?php
include("../phpscripts/dbc.php");
$resource=$_GET['resource'];
$posting_username=$_POST['username'];
$posting_comment=$_POST['comment'];
$comments="Comments:<br>";
$SQL=" SELECT * FROM comments ";
//$SQL = $SQL . " WHERE category = '$category' ";
$retid=mysql_db_query($db, $SQL, $cid);
while($row = mysql_fetch_array($retid)) {
$posted_username=$row["username"];
$posted_comment=$row["comment"];
$comments=$comments.="<br>$posted_username said: $posted_comment";
}
if ($logged=="yes") {
if($_SERVER['REQUEST_METHOD']=="POST") {
$SQL=" INSERT INTO comments ";
$SQL=$SQL . " (username, resource, comment) VALUES ";
$SQL=$SQL . " ('$posting_username', '$resource', '$posting_comment') ";
$result=mysql_db_query($db,"$SQL",$cid);
if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); }
}
$commentbox="Please use the below box to comment.
<br>
<br>
<form name=\"comment\" action=\"index.php?resource=$resource\" method=\"POST\">
<input name=\"username\" type=\"hidden\" value=\"$user\">
<textarea name=\"comment\" class=\"descr_field\">
</textarea>
<br>
<br>
<div class=\"button\">
<a href=\"#\" onClick=\"document.comment.submit();\">
Comment
</a>
</div>
</form>";
}
else {
$commentbox="You must be logged in to comment, please login of create an account.";
}
Tim