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

  • Home
  • SEARCH
  • 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 8479609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:04:47+00:00 2026-06-10T19:04:47+00:00

I have a for loop which loops through an array of results from a

  • 0

I have a for loop which loops through an array of results from a MySQL query.

The query selects all rows from the table wait_times of which the logged in user has created, and is as follows:

SELECT * FROM `wait_times` WHERE `user_id` = ?

My problem is that I need to retrieve the venue information for each row. At the moment, I am looping through that array and sending an individual request to foursquare for the venue’s information. This method can be incredibly slow depending on the amount of rows that have been returned from the query.

In order to speed this up, I plan on storing the venue information in a separate table, which should ultimately be quicker than sending a curl request to the Foursquare API.

Please could you tell me if there are any other ways that could speed this process up?

I looked into multi queries, but the user may not have an account with Foursquare and the API requires the user to be signed up and logged in.

Here is my code:

$query = $this->db->query("SELECT * FROM `wait_times` WHERE `user_id` = ?", array($uid));

$wait_times = $query->result();

foreach ($wait_times as $wait_time) {

    $wait_time->venue = $this->venue_info($wait_time->venue_fq_id);

}

function venue_info($vid) {

    $v = date('Ymd');
    $url = "https://api.foursquare.com/v2/venues/{$vid}?client_id=" . FQ_CLIENT_ID . "&client_secret=" . FQ_CLIENT_SECRET . "&v={$v}";
    curl_setopt($this->ch, CURLOPT_URL, $url);
    $resp = curl_exec($this->ch) or die(curl_error($this->ch));
    $json = json_decode($resp, TRUE);

    if ($json['meta']['code'] == 400)
         return FALSE;

    $venue = $json['response']['venue'];

    return $venue;

}
  • 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-10T19:04:48+00:00Added an answer on June 10, 2026 at 7:04 pm

    You could do some form of caching? I would highly recommend switch to a reference table instead. FS might have some rule on API requests and you could end up being blacklisted. Any form of HTTPS communication is slow due to the multiple handshakes. If you can, invest time into a table. You could even cheat and use serialized objects.

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

Sidebar

Related Questions

I have a foreach loop which loops through an array (simpleXML nodes). This array
I have created an array of data, from which I can loop through specific
I have a multidimensional array which I am looping through using a foreach loop.
I have an application which needs to loop through all the lines in text
i have a function which retrieves values from a webservice , then loops through
Possible Duplicate: php loop through associative arrays i have a variable which prints an
Possible Duplicate: php loop through associative arrays i have this piece of code which
I have the below but want to only loop through lines in #lines which
I have a page which displays my database information. Through each loop, there is
I have multiple foreach loops through which i am fetching the work history ,

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.