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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:58:44+00:00 2026-06-16T02:58:44+00:00

Somewhat stupid question, I’m sure, bud I do need an answer. I’m doing this

  • 0

Somewhat stupid question, I’m sure, bud I do need an answer.

I’m doing this short learning project where I need to get a database to output some JSON.

I do know how to structure tables, but due to my very short history with them, I’ve not figured out how to deal with an array of objects within a tablecell (in this example, the pointsOfInterest and events). Should I make separate tables for them and somehow leave a reference to the separate tables for each one? And how do I deal with them in php?

TL:DR; How should I structure my database to allow for JSON output like this?:

{id: 'oyafestivalen',
 displayName: 'Øyafestivalen 2011',
 description: 'Music festival in Middelalderparken, Oslo',
 pointsOfInterest: [
   {id: 'sjosiden',
    displayName: 'Sjøsiden',
    lat: 59.904453,
    lng: 10.762905},
   {id:   'vika',
    displayName: 'Vika',
    lat:  59.906086,
    lng: 10.763276},
   {type: 'wc',     // type is optional, defaults to 'venue'
    // displayName optional, not specified here
    lat: 59.903625,
    lng: 10.763276},
   {type: 'firstaid',
    lat: 59.903625,
    lng: 10.763276},
   {type: 'entrance',
    lat: 59.903625,
    lng: 10.763276},
   {type: 'exit',
    lat: 59.903625,
    lng: 10.763276},
   {type: 'camping',
    lat: 59.903625,
    lng: 10.763276},
   {type: 'food',
    displayName: 'Random restaurant name',
    description: 'They serve good food. Vegetarian-friendly',
    lat: 59.903625,
    lng: 10.763276},
   {type: 'drinks',
    displayName: 'Random bar name',
    lat: 59.903625,
    lng: 10.763029}
 ],
 events: [
   {displayName: 'Kyuss Lives!',
    venue: 'sjosiden',
    startDateTime: '2011-08-13T19:30',
    endDateTime: '2011-08-13T21:00',
    tags: ['rock', 'stoner']},
   {displayName: 'Givers',
    description: 'Givers are an indie pop group from Lafayette, Louisiana. The band is made up     of...',
    venue: 'vika',
    // Default one hour duration if no endTime
    startDateTime: '2011-08-13T18:05',
    tags: ['pop', 'indie']}
 ]
  • 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-16T02:58:45+00:00Added an answer on June 16, 2026 at 2:58 am

    I can’t possibly tell you the structure of your tables nor can i tell you the exact queries you need to execute to get that output, but i can tell you this:

    You can’t possibly produce such an output from an SQL query. However you can construct such an output with multiple queries and manipulate their output with PHP to construct your multi-dimension array. For example the content of pointsOfInterest should be a separate query. To help you get the desired output use print_r() in PHP to check how your array is going. Once you get what you want, use json_encode() to convert the array into a json string in PHP.

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

Sidebar

Related Questions

Somewhat related to this question , but in the absence of any answer about
I am somewhat new to web development, so I'm not sure how stupid this
I feel stupid asking this question, but I can not find a clear answer
I know the question sound somewhat stupid, but i have this scenario. Context I
Somewhat similar to this question , except we haven't decided that we're going with
So probably somewhat of a stupid question but here it goes. If you download
It feels like this is a colossally stupid question, but the documentation for rar
I'm somewhat new to PHP, so this will probably sound stupid, but how you
Somewhat on the back of this question that asks about the behaviour of the
Although somewhat related to this question , I have what I think is a

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.