Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: SQL Doubling

  1. #11
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default

    I planned on:

    Comments:<br>

    <br>$posted_username

    That way 2 linebreaks before the first comment then one inbetween each comment.

  2. #12
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    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

  3. #13
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default

    No, no. Sorry I explained it wrong man heres a copy of the actual script:

    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.";
    }
    Thanks for all your help everyone.


    Tim

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •