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 8327373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:05:18+00:00 2026-06-09T01:05:18+00:00

I’m trying to select various bits of data out of my insert.php page. Such

  • 0

I’m trying to select various bits of data out of my insert.php page. Such as post id, username and users id so far.. And I will be adding other bits of selected data. Now I could get the id of the div with response, but when I added more queries and echo them out they ended up all together so I had my postidusernameuserid all in one string. How do I separate them?

Also I’m aware of the depreciated MYSQL_ I just haven’t got around to updating my code yet.

AJAX

 <script>
    $(document).ready(function(){
        $("form#myform").submit(function(event) {
            event.preventDefault();
            var content = $("#toid").val();
            var newmsg = $("#newmsg").val();

            $.ajax({
                type: "POST",
                url: "insert.php",
                data: {toid:content, newmsg: newmsg},
                success: function(response){
                    $("#homestatusid").prepend("<div id='divider-"+response+"'><div class='userinfo'>"+newmsg+"<a href='/profile.php?username="+response+"'><img class='stream_profileimage' style='border:none;padding:0px;display:inline;' border=\"0\" src=\"imgs/cropped"+response+".jpg\" onerror='this.src=\"img/no_profile_img.jpeg\"' width=\"40\" height=\"40\" ></a><div style='cursor:pointer;position:relative;top:0px;float:right;padding-right:5px;' onclick=\"delete_('"+response+"');\">X</div></div></div>");
                }
            });
        });
    });
    </script>

INSERT.PHP

$check = "SELECT streamitem_id FROM streamdata";
        $check1     =    mysql_query($check);
        $resultArr = mysql_fetch_array($check1);
    echo $resultArr['streamitem_id'];

$check = "SELECT username,id FROM users";
        $check1     =    mysql_query($check);
        $resultArr = mysql_fetch_array($check1);
    echo $resultArr['username'];
    echo $resultArr['id'];

Is it a case of success: function(response,responsetwo){ and so on.

  • 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-06-09T01:05:20+00:00Added an answer on June 9, 2026 at 1:05 am

    In PHP try returning the data in JSON format.

    echo json_encode(array);
    

    The response variable in JavaScript will be an object you can get the data from.

    console.log(response['username']);
    

    JavaScript:

    $(document).ready(function(){
        $("form#myform").submit(function(event) {
            event.preventDefault();
            var content = $("#toid").val();
            var newmsg = $("#newmsg").val();
    
            $.ajax({
                type: "POST",
                url: "insert.php",
                dataType: "json",
                data: { toid: content, newmsg: newmsg },
                success: function(response){
                    $("#homestatusid").prepend("<div id='divider-"+response['streamitem_id']+"'><div class='userinfo'>"+newmsg+"<a href='/profile.php?username="+response['username']+"'><img class='stream_profileimage' style='border:none;padding:0px;display:inline;' border=\"0\" src=\"imgs/cropped"+response['id']+".jpg\" onerror='this.src=\"img/no_profile_img.jpeg\"' width=\"40\" height=\"40\" ></a><div style='cursor:pointer;position:relative;top:0px;float:right;padding-right:5px;' onclick=\"delete_('"+response['id']+"');\">X</div></div></div>");
                }
            });
        });
    });
    

    PHP:

    $json = array();
    $check = "SELECT `streamitem_id` FROM `streamdata`";
    $check1 = mysql_query($check);
    $resultArr = mysql_fetch_array($check1);
    $json['streamitem_id'] = $resultArr['streamitem_id'];
    mysql_free_result($check1);
    
    $check = "SELECT `username`, `id` FROM `users`";
    $check1 = mysql_query($check);
    $resultArr = mysql_fetch_array($check1);
    $json['username'] = $resultArr['username'];
    $json['id'] = $resultArr['id'];
    mysql_free_result($check1);
    
    echo json_encode($json);
    

    I took the liberty of guessing where you wanted to use ‘username’, ‘id’, and ‘streamitem_id’.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to select an H1 element which is the second-child in its group
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.