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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:08:04+00:00 2026-05-31T15:08:04+00:00

I managed to output the column ‘resort’ in the Json array, but I need

  • 0

I managed to output the column ‘resort’ in the Json array, but I need ‘country’ too, as well as ‘aantal’. Have no idea how to do that. Can someone please help me?

if ($numrows < 1 && strlen($sq) > 3)
{
        $sql = "SELECT resort, country, COUNT(image) AS aantal FROM sx_cam
          LEFT JOIN sv_orte ON sv_cam.res_id = sv_orte.res_id
          WHERE sound=soundex('$sq') and (status < 1) GROUP BY resort order by aantal desc";
        $result2 = mysql_query($sql) or die(mysql_error());
        $numrows = mysql_num_rows($result2);
        $suggest = 2;
}

$items = array();

while($row = mysql_fetch_assoc($result2)){
 $items[$row['resort']] = $row['resort'];
}

foreach ($items as $key=>$value) {
 echo strtolower($key)."|$value\n";
}
  • 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-05-31T15:08:06+00:00Added an answer on May 31, 2026 at 3:08 pm

    You’re building the array the wrong way. Once you get the array right, it is as simple as making a call to json_encode

    I’m not entirely sure how you want your json to look, but something like this should get you started

    $items = array();
    
    while($row = mysql_fetch_assoc($result2)){
    
        //first we build an 'object' of the current result
        $item['country'] = $row['country'];
        $item['resort'] = $row['resort'];
    
        //now push it on the array of results
        $items[] = $item;
    }
    
    echo json_encode($items);
    

    Once you get the above code working, you can tweak the PHP array to change the structure of the JSON to suit your needs.

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

Sidebar

Related Questions

I managed to show the output of a shell command in TextArea of flex
I managed to get some help from a previous question and I have the
Does managed C++ have an equivalent to C#'s lock() and VB's SyncLock? If so,
I managed to get the YUI calendar widget working fine. But When it displays
I managed to get Ubuntu running on a mobile device. I need to automate
I managed to read a web page into a string, but when I print
I need to sort the output of a find on a HP-UX. I've got
I have just managed to write my first windows driver (havent registered it yet-
I have a column A which contain 4 fields separated by ‘/’ example: 234-12-343/653423/MANAGER/yg@gmail.com
I have an xml column and I want to persist a node count in

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.