Add comment images JQuery and PHP

    Rating: ★★★★☆
    View: 520
    Download: 306
    Từ khóa:

    "Upload"  Table
      Upload  table contains all comment and name of image that uploaded . 

    CREATE TABLE  `upload` (
    
     `img_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    
     `comment` VARCHAR( 50 ) NOT NULL ,
    
     `img` LONGTEXT NOT NULL
    
    ) ENGINE = MYISAM ;

     
    "jQuery" send data with "ajax" Codes  "index.php"
          Ajax send values of comment box and image to php page that's  named  " send.php " without reload browser . 

    $.ajax({
    
            type: "POST",
    
            url: "send.php",
    
            data:datarps, 
    
             cache: false,
    
              
    
      success: function(html){
    
     $("#preview").html("");
    
     $("#im_but").val("");
    
      $("#update").prepend(html);
    
        $("textarea").val(""); 
    
      }
    
     });
    

    Insert values into database after strips tags 
    familiar Sql code used to insert value into database 

    $sq=mysql_query("INSERT INTO `upload`  (comment,img)
    
     VALUE ('$rq','$imval')");
    
    $sql= mysql_query
    
    ("SELECT comment,img FROM `upload` order by img_id desc");
    
    $c=mysql_fetch_array($sql);
    
    $comment=$c['comment'];
    
    $img=$c['img'];
    

     

    loading Đang tải...

    template được ưa chuộng