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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:23:20+00:00 2026-06-16T18:23:20+00:00

Form a php page I am sending some value using json. $result = mysql_query(SELECT

  • 0

Form a php page I am sending some value using json.

$result = mysql_query("SELECT * FROM user_info");


    $i=1;
    while($row = mysql_fetch_array($result, MYSQL_NUM)) {
        if(is_array($row) && count($row)>0) 
        {
            $res['user_name'.$i]         = $row[1];
            $res['user_email'.$i]           = $row[2];
            $res['gender'.$i]           = $row[4];
            $res['i']                   = $i;
            $i++;
        }
    }

echo json_encode($res);

I have no problem with this code.But in another page I want to get that data code follows

    $.post(urlName, function(data) {
    var obj = jQuery.parseJSON ( data );
    $noOfUser   = obj.i;
    alert("No of user- "+$noOfUser);

    for($i=0;$i<=$noOfUser;$i++)
    {
    $user_name = obj.user_name+$i;
    $user_emai = obj.user_email+$i;
    $gender    = obj.gender+$i;

    alert("User Name- "+$user_name);
    alert("User Email- "+$user_emai);
    alert("User Gender- "+$gender);
    }
    });

But the problem is when I am adding this obj.user_name+$i instead of simple obj.user_name it can’t retrieve the data properly but I need to get those value how to do that?

  • 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-16T18:23:21+00:00Added an answer on June 16, 2026 at 6:23 pm

    What you are trying to do attempts to get the user_name member of obj and appending the value of $i. Since user_name is not defined, the script fails.

    This is because in javascript to access a member of an object using a dynamically generated key you must use the [] accessor, so in your case, the following example should work.

    $user_name = obj['user_name' + $i];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am sending a json string using JQuery.ajax to a php page where I
I've a php page with some forms used to upload images. Each form upload
In my application am submiting my form by using post for a php page.
I tried sending some data like so: <form action=http://www.someurl.com/something.php id=login> <input type=textbox id=UserName value=user>
I'm sending a form to a php page, which then saves to a mysql
I am sending POST data to PHP webpage from my windows app using VB.net.
I have a 3-part registration form using PHP: page 1 : collects info -
Im trying to encode some html within json from PHP. The function requests data
Hi guys i am using the mail() from the contact form and for some
I have a php page called form.php. When you go to this page it

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.