Database Articles

  Home arrow Database Articles arrow Page 6 - PHP/MySQL News with Comments
DATABASE ARTICLES

PHP/MySQL News with Comments
By: Matt Wade
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 28
    2002-09-03

    Table of Contents:
  • PHP/MySQL News with Comments
  • The Tables
  • Displaying the news
  • Displaying the comments
  • Displaying one item with comments
  • Adding comments
  • Summing it up and final script

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    PHP/MySQL News with Comments - Adding comments


    (Page 6 of 7 )

    So, what’s left? We need to provide the backend for what happens when a user types in a comment. We will simply take the form input and insert it in the comments table. Then, provide a link back to the page they came from.

    <?php
    function addComment($id) {
        global 
    $db;
        
        
    /* insert the comment */
        
    $query "INSERT INTO news_comments " .
                 
    "VALUES('',$id,'{$_POST['name']}'," .
                 
    "'{$_POST['comment']}')";
        
    mysql_query($query);
        
        echo 
    "Comment entered. Thanks!&lt;BR&gt;\n";
        echo 
    "&lt;a href=\"{$_SERVER['PHP_SELF']}" .
             
    "?action=show&amp;id=$id\"&gt;Back&lt;/a&gt;\n";
    }
    ?>

    More Database Articles Articles
    More By Matt Wade

    blog comments powered by Disqus

    DATABASE ARTICLES ARTICLES

    - Completing a Book Inventory Management System
    - Uploading Images for a Book Inventory Manage...
    - Finishing the Add Book Story for a Book Inve...
    - Integration Testing for a Book Inventory Man...
    - User Stories for a Book Inventory Management...
    - Unit Testing a Book Inventory Management Sys...
    - Testing a Book Inventory Management System
    - Implementing Models for a Book Inventory Man...
    - Book Inventory Application: Publishers and B...
    - Handling Publishers in a Book Inventory Mana...
    - Publisher Administration for Book Inventory ...
    - Book Inventory Management
    - Using the SQL Reference Manual
    - Using Oracle SQL Developer with SQL Statemen...
    - Fixing Errors with Oracle SQL Developer


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap