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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:17:16+00:00 2026-06-06T14:17:16+00:00

I do not know what I am doing when it comes to JSON. So

  • 0

I do not know what I am doing when it comes to JSON. So this may be a stupid question and I may be trying to do it a weird way. Any help would be great.

I have this Jquery Calendar I am trying to put on my website. It allows for json_encode for dates. Here is the example they gave.

    $year = date('Y');
$month = date('m');

echo json_encode(array(

    array(
        'id' => 111,
        'title' => "Event1",
        'start' => "$year-$month-10",
        'url' => "http://yahoo.com/"
    ),

    array(
        'id' => 222,
        'title' => "Event2",
        'start' => "$year-$month-20",
        'end' => "$year-$month-22",
        'url' => "http://yahoo.com/"
    )

));

I want to use an existing mySQL database to populate the calendar. Here is what I have so far. It isn’t working and I don’t think I am being intelligent with this.

$dataSQL ="select *
            FROM events
        ";

$dataResult = mysqli_query($dataBase, $dataSQL);

$encode = array();

$p=0;
    while($allRow = mysqli_fetch_array($dataResult))
        {
            $new = array(
                        'id' => "$allRow['id']",
                        'title' => "$allRow['title']",
                        'start' => "$allRow['date']",
                        'url' => "$allRow['url']"
                    );
            array_splice($encode, ($p), 0, $new);

            $p++;
        }


echo json_encode($encode);

Thanks in advance!

  • 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-06T14:17:18+00:00Added an answer on June 6, 2026 at 2:17 pm

    If you’re just having problems with your array structure, you’ve gone a bit complex. You can build an array like this:

    $encode = array();
    
    while($allRow = mysqli_fetch_array($dataResult))
           {
                $new = array(
                            'id' => $allRow['id'],
                            'title' => $allRow['title'],
                            'start' => $allRow['date'],
                            'url' => $allRow['url']
                        );
                $encode[] = $new;
    
            }
    
    echo json_encode($encode);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this probably really simple but Im not sure what im doing wrong...
I'm mot sure if I'm doing this wrong or not I don't know if
I know this specific question has been asked before , but I am not
I don't know what I'm not doing but I simply cannot get my own
Is it possible to use reflection to know what the code is doing, not
I do not know if this is possible, but here goes. And working with
Somewhere some guy said (I honestly do not know where I got this from),
This ajax thing im working on is not doing what i tell it to
Something that I would assume comes up a lot... I'd like to know if
this might be an easy question but for me right now it is not

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.