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

  • Home
  • SEARCH
  • 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 8232779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:56:34+00:00 2026-06-07T17:56:34+00:00

I am trying to retrieve like several different values from a table. I got

  • 0

I am trying to retrieve like several different values from a table. I got it working, but it is actually only sending me the last value it calls. I have done several different things trying to call all my values, but it is not working. Here is what I have.

$infoChanger = $_GET['changer'];
$username = $_GET['user'];
$sql="SELECT * FROM Login_Info WHERE user='".$username."'";
$r = mysql_query($sql,$con);
$row = mysql_fetch_array($r);

if ($row[7] != "") 
{
    if ( $infoChanger == 1 ) {
        echo $row['user'];
    }
    else if ( $infoChanger == 2 ) {
        echo $row['health'];
    }
    else if ( $infoChanger == 3 ) {
        echo $row['maxHealth'];
    }
    else if ( $infoChanger == 4 ) {
        echo $row['gold'];
    }
    else if ( $infoChanger == 5 ) {
        echo $row['xp'];
    }
    else if ( $infoChanger == 6 ) {
        echo $row['xpRequire'];
    }
    else if ( $infoChanger == 7 ) {
        echo $row['eg'];
    }
}
else
{
    echo "false";
}

This was my last attempt to try to do it. But it only return the value of the last one “eg”. I have it set on an a loop to call here is what I use to call it.

function recallCharInfo(user)
{
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
      alert ("Browser does not support HTTP Request")
      return
    }
    while (infoChanger < 7) {
      infoChanger += 1;
      xmlHttp=GetXmlHttpObject();
      var url="charinfo.php?user=" + user + "&changer=" + infoChanger;
      xmlHttp.onreadystatechange=stateChanged
      xmlHttp.open("GET",url,true)
      xmlHttp.send(null);
    }
}

I am trying to get them all to display, but just isn’t working the way and I don’t want to make a function for each one value I am trying to call. Does anyone know what is wrong with this or have I just done this wrong?

  • 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-07T17:56:36+00:00Added an answer on June 7, 2026 at 5:56 pm

    For your specific case, array indexes start at 0, so if those are all the rows in your array $row[7] will never be anything, and will always return false.

    Your initial check should be:

    if($row !== false && $row[6] != "") 
    

    For an alternate solution to looping:

    You’re php can be:

    $infoChanger = $_GET['changer'];
    $username = $_GET['user'];
    $sql="SELECT * FROM Login_Info WHERE user='".$username."'";
    $r = mysql_query($sql,$con);
    $row = mysql_fetch_array($r);
    echo json_encode($row);
    

    That should return the whole row as a JSON object which you can then parse into a Javascript object in your success method with:

    var rowData = JSON.parse(data);
    

    Then you should be able to access all your fields with

    rowData.user;
    and
    rowData.health;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m trying to retrieve data from an entity and populate a viewModel property like
Iam trying to retrieve data from mysql database into stylesheet.php but it is not
Hi I am trying to retrieve values from database. I have a row which
I am trying to retrieve a column from another related table, and display that
I am trying to retrieve particular data from a txt file and would like
i have tried several methods of trying to extract values from an XML file
I'm trying to retrieve the last updated date from a cube. I have a
I am trying to retrieve query string values from a url. And the app
I'm trying to retrieve books from one table and left join the chapters table.
I have been have issues trying to retrieve the values from a treeMap that

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.