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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:55:33+00:00 2026-06-08T09:55:33+00:00

So I have a php script that does this: $rows = array(); while($r =

  • 0

So I have a php script that does this:

$rows = array();        
while($r = mysql_fetch_assoc($sth2)) {
 $rows[] = array($r['alternative'] => $r['amount']);
}
print json_encode($rows);

I get this output:

[{"\u00e5l":"3"},{"vin":"3"},{"whiskey":"1"},{"gin":"1"},{"rom":"1"},{"vodka":"1"}]

Problem one: \u00e5 is supposed to be ø. Everything else works with utf8 except this very function, any idea how to fix this?

Second problem is that I cannot seem to get a nice way of reading the data in javascript. I am currently using this code (I know’s not that good, but it should work for now):

$.each(obj, function(key, val) 
{
counter = counter +1 ;
switch (counter)
    {
        case 0:
            numberOne = key;
            valueOne = val;
            break;
        case 1:
            numberTwo = key;
            valueTwo = val;
            break;
        case 2:
            numberThree = key;
            valueThree = val;
            break;
        case 3:
            numberFour = key;
            valueFour = val;
            break;
        case 4:
            numberFive = key;
            valueFive = val;
            break;
        case 5:
            numberSix = key;
            valuesix = val;
            break;
    }
});
  • 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-08T09:55:34+00:00Added an answer on June 8, 2026 at 9:55 am

    for your second problem you can use

    for(a in obj)
    {
      alert(a +' = '+obj[a]);
    }
    

    You havn’t specified what you want to achive by reading object properties So I left it to you 🙂 hope it helps.

    edited :

    for(a in obj)
        {
          alert(a +' = '+obj[a]);
          for(b in obj[a])
          {
            alert(b+' = '+obj[a][b]); // or   alert(b+'  '+obj[a].b); would work  
          }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script that does this: $sec = 1; $id = 1;
I have a PHP script that does the following: Uses file_get_contents() to get content
I have a PHP script that does basic encryption of a string through the
Need your help with my PHP/MYSQL array. I have a php script that selects
I have a PHP script that processes my email subscriptions. It does something like:
I'm currently working on a PHP/MySQL script that does the following, in this order:
I have a login script that does this: $_SESSION['username']=$username; $_SESSION['password']=$password; If the user logged
I have a PHP script that does the following: It takes a string, for
I have a php script that does some processing (creates remittance advice PDFs, self-billing
I have a PHP script that runs as a background process. This script simply

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.