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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:33:39+00:00 2026-06-13T16:33:39+00:00

So im trying to figure out the best way to get MySql table data

  • 0

So im trying to figure out the best way to get MySql table data into either a multidimensional PHP array or convert that multidimensional array into a json string.

Essentially what im trying to do is have a php include that returns the JSON string so i can iterate through it. I am needing a single key with multiple values, so im not 100% sure that im headed in the right direction.

I want to assign multiple values to the same key, for example:

[{"key1": "package1", "package2", "package3"}, {"key2": "package1", "package2", "package3", "package4"}]

I think that is not going to work right? Because i dont have any type of index’s?

  • 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-13T16:33:40+00:00Added an answer on June 13, 2026 at 4:33 pm

    That is not valid JSON. The structure you are looking for would be something like:

    [
     {"key1": ["package1", "package2", "package3"]},
     {"key2": ["package1", "package2", "package3", "package4"}]
              ^ An array as the value to the key "key1", "key2", etc..
    ]
    

    At the PHP side, you would need something like:

    1. For every row fetched from MySQL
      • $arr[$key] = <new array>
      • for each package:
        • append package to $arr[$key]
    2. echo out json_encode($arr)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out the best way to get the pixel color value
I'm trying to figure out the best way to put complex numbers into my
I'm trying to figure out whats the best way to get checkboxes to properly
I'm trying to figure out the best way to get everything before the -
I am currently trying to figure out the best way to get a entity
I'm trying to figure out the best way to insert a record into a
I'm trying to figure out the best way to validate data within a MVC
I'm trying to figure out there best way to define a global array with
Trying to figure out the best way to get the web page the user
Trying to figure out the best way to set up collection lists for users

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.