Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5932301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:48:55+00:00 2026-05-22T14:48:55+00:00

$idc = $_GET[‘id’]; $name1 = $_GET[‘name’]; $id2 = $_GET[‘ids’]; if ($_POST[‘message_field’] != ){ $message_field

  • 0
 $idc = $_GET['id'];
    $name1 = $_GET['name'];
    $id2 = $_GET['ids'];
     if ($_POST['message_field'] != ""){
        $message_field = $_POST['message_field'];

          $sql = mysql_query("INSERT INTO comment (mem_id,commented_men_id, message, message_date) 
         VALUES('$userid','$idc','$message_field', now())")  
         or die (mysql_error());

    }

        $sql_message = mysql_query("SELECT id, mem_id ,message, message_date FROM comment WHERE mem_id='$userid'  ORDER BY message_date DESC");

        while($row = mysql_fetch_array($sql_message)){


            $id = $row["id"];
            $me_id = $row["mem_id"];
            $json = $row["message"];
                 $message_date = $row["message_date"];
                $message = json_encode($json);

 $sql_mem_data = mysql_query("SELECT id, name FROM users WHERE  id='$me_id'");
              while($row2 = mysql_fetch_array($sql_mem_data)){
                $id = $row2["id"];
                $ufirstname = $row2["name"];
        }

    $messageList .= '<div id="only"><p>' . ufirstname . '</p><br/><p    id="pmessage">'.$the_message.'</p></div>';

    }

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title> Book</title>
    <link rel="stylesheet" href="style/style.css" type="text/css" media="screen" />
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="jquery.form.js"></script>
    <script type="text/javascript" src="mootools-core-1.3.2-full-compat.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){

       $("#messageinput").click(function() {
           $.post($('#message').attr("action"),
                  $("#message").serialize(),
                  function(html) {
                    var comment = $(html) .find('#messageoutput').html();
                      $("#pmessage").html(comment);
              });
   });
       });

    </script>
         <div id="messageid">
             <form align="left" id="message" action="<?php profile.php?id='.$idc.'& ids='.    $id2.'&name='.$name1.'?>" method="post" enctype="multipart/form-data" name="blab_from">
        <textarea name="message_field" rows="3" style="width:97%;"></textarea>
         <input id="messageinput" name="submit" type="button" value="submit" align="left" />
        </form>
        </div>
        <div id="messageoutput"><?php print "$messageList"; ?></div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:48:56+00:00Added an answer on May 22, 2026 at 2:48 pm

    You can do it like this… Suppose this is your html

    <form align="left" id="form1" action="" method="post"   enctype="multipart/form-data" name="message_from">
    <textarea id="message_field" name="message_field" rows="3" style="width:97%;"></textarea>
    <input id="messageinput" name="submit" type="button" value="Submit" align="left" />
    </form>
    <div id="result"></div>
    

    Then the following code will submit the form data and will echo the result back in the ‘data’ variable. You can do whatever you want to do with the return data then. Like in the example i am putting the returned data in a div with id=”result”.

    $(document).ready(function(){
        $("#messageinput").click(function(){
            $.post('html.php',$("#form1").serialize(),function(data){
                $("#result").html(data);
            });
    
        });
    });
    

    Solution to your modified script

    <?php
    //engine.php
    //for convinence sake split the php and html into 2 files say php is in engine.php and html in profile.php
    //why are you using &name and &ids for? my best guess is u need only &id and &message_field if its a msg post
    
    //this file will do 2 things when id is passed return the comments and when id and message is passed insert the comment into db fetch it again and pass it.
    //the html manipulation will be done by jQuery/javascript only you dont need php for that
    
    //  $idc = $_GET['id'];
    //  $name1 = $_GET['name'];
    //  $id2 = $_GET['ids'];
    
        $idc = $_POST['id'];//[we are using post so use _POST methods]
    
    
        if ($_POST['message_field'] != "")
        {
            //here you are missing connection statements like mysql_connect() and mysql_select_db()
            $message_field = $_POST['message_field'];
            $sql = mysql_query("INSERT INTO comment (mem_id,commented_men_id, message, message_date)VALUES('$userid','$idc','$message_field', now())") or die (mysql_error());  
        }
    
        $sql_message = mysql_query("SELECT id, mem_id ,message, message_date FROM comment WHERE mem_id='$userid'  ORDER BY message_date DESC");
    
        $i = 0;
        $messageList = '<div id="result">';
        while($row = mysql_fetch_array($sql_message))
        {
            $j=$i++;
            $id = $row["id"];
            $me_id = $row["mem_id"];        
            $message_date = $row["message_date"];
            //$json = $row["message"];
            //$message = json_encode($json);
            $message = $row["message"]; //disabling json for now
    
            $sql_mem_data = mysql_query("SELECT id, name FROM users WHERE  id='$me_id'");
    
            while($row2 = mysql_fetch_array($sql_mem_data))
            {
                $id = $row2["id"];
                $ufirstname = $row2["name"];
            }
            //$messageList .= '<div id="only"><p>' . ufirstname . '</p><br/><p    id="pmessage">'.$the_message.'</p></div>'; //[error 1] ur writting this outside while loop also id="only" multiple times will create error same with id="pmessage"
            /*[error 1] rectification*/ $messageList .= '<div id="row_'.$j.'"><p id="uname_'.$j.'">'.$ufirstname.'</p><br/><p id="msg_'.$j.'">'.$message.'</p></div>';
        }
        $messageList .= '</div>'; //making id="result" parent of all the rows
        echo $messageList; //script has to echo for jQuery to catch it.
    ?>
    <!--This file is profile.php(assumption)-->
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title> Book</title>
    <link rel="stylesheet" href="style/style.css" type="text/css" media="screen" />
    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
    <script type="text/javascript" src="jquery.form.js"></script>
    <script type="text/javascript" src="mootools-core-1.3.2-full-compat.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    /*i still didn't get why you use $id2 and &name2 but the above php block is used to only fetch data which is passed by the javascript
    so you need 2 events first when the page is loaded and 2nd when the page is posted with a new comment
    */
    (function($)
    {
        $.getParam = function(key)
        {
            var urlParams = decodeURI( window.location.search.substring(1) );
            if(urlParams == false | urlParams == '') return null;
            var pairs = urlParams.split("&");
    
            var keyValue_Collection = {};
            for(var value in pairs)
            {
                var equalsignPosition = pairs[value].indexOf("=");
                if (equalsignPosition == -1) 
                    keyValue_Collection[ pairs[value] ] = ''; 
                else
                    keyValue_Collection[ pairs[value].substring(0, equalsignPosition) ] = pairs[value].substr(equalsignPosition + 1);
            }
            return keyValue_Collection[key];
        }
    })
    (jQuery);
    
    //fetch the id to get the messages
    var id = $.getParam("id");
    
    //if its a click
    $("#messageinput").live('click',function(){
        var msg = $("#message_field").val();
        var qstring='id='+id+'&message_field='+ msg;
        $.post('engine.php',qstring,function(data){
            $("#messageoutput").html(data);//bind the whole data to messageoutput div as its already formatted for right html
        });
    });
    
    //else load default messages
    var qstring = 'id='+id;
    $.post('engine.php',qstring,function(){
        $("#messageoutput").html(data);//in this php script will return only the messages for the passed id.
    });
    
    });
    </script>
    <div id="messageid">
        <form align="left" id="message" action="" method="post" enctype="multipart/form-data" name="blab_from">
        <textarea id="message_field" name="message_field" rows="3" style="width:97%;"></textarea>
        <input id="messageinput" name="submit" type="button" value="submit" align="left" />
        </form>
    </div>
    <!--<div id="messageoutput"><?php/* print "$messageList"; */?></div>--> <!--This is not needed when u do it by AJAX simply put an empty div for results-->
    <div id="messageoutput"></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code below is just a sample of the format I have isset($_GET['ids'])?$ids=$_GET['ids']:null; isset($_POST['idc'])?$idc=$_POST['idc']:null;
<?php switch($_GET[action]) { case add_item: { AddItem($_GET[idc], $_GET[qty]); ShowCart(); break; } case update_item: {
switch($_GET[action]) { case add_item: { AddItem($_GET[ids], $_GET[qty]); ShowCart(); break; } default: { ShowCart(); }
I am having a problem with a sql view. My actual views encompass several
My question is how oracle treats an INSERT transaction before issuing a COMMIT. While
c = (f.profile_id = #{self.id} OR f.friend_id = #{self.id}) c += AND + (CASE
I can use GetDlgItemText to get the text from a control, but I want
I'm trying to get this simple windows dialog to spawn but as soon as
having trouble getting my directx going I get the following error 1>Linking... 1>main.obj :
I create a simple window with a comboboxex (with inserting few bitmaps), I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.