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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:47:09+00:00 2026-06-14T17:47:09+00:00

Below you will find my code, it’s not it all in it’s entirety, but

  • 0

Below you will find my code, it’s not it all in it’s entirety, but shows what’s important. I have some custom functions that are being used just to note out. What I have my code doing is searching a MySQL table and displaying all of the results based on the current session user id. Then I loop through those results and for each one I search another table. This works perfectly, but I just want to see if there is a better way to do this without having to loop and search a table for every result row

<?php
$table_sql = "SELECT * FROM participation WHERE shop_id = '{$session->user_id}'";
$result = $database->query($table_sql);
$participation = array();
while ($row = $database->fetch_array($result)) {
        $participation[] = array (
                'shop_id'               => $row['shop_id'],
                'qpon_id'           => $row['qpon_id'],
                'distributor_id'        => $row['distributor_id']
        );
}
$qpons = array();
if (isset ($participation)) {
        if (!empty ($participation)) {
                foreach ($participation as $qpon) {
                        $table_sql = "SELECT * FROM qpons WHERE id = '{$qpon['qpon_id']}'";
                        $result = $database->query($table_sql);

                        while ($row = $database->fetch_array($result)) {
                                $qpons[] = array (
                                        'id'                    => $row['id'],
                                        'service'       => $row['service'],
                                        'start_date'    => $row['start_date'],
                                        'end_date'      => $row['end_date']
                                );
                        }
                }
        }
}


if (isset ($qpons)) {
if (!empty ($qpons)) {
foreach ($qpons as $value) {

echo '<tr>';
echo '<td>' . $value['service'] . '</td>';
echo '<td>' . $value['start_date'] . '</td>';
echo '<td>' . $value['end_date'] . '</td>';
echo '<td>' . $value['id'] . '</td>';
echo '<td class="action_icon"><a href="admin-edit.php?id=' . $value['id'] . '"><img src="images/icons/view.png" alt="View"></a></td>';
echo '</tr>';

}

} else {
echo '<tr>';
echo '<td>No Results Found!</td>';
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '</tr>';
}

}
?>
  • 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-14T17:47:10+00:00Added an answer on June 14, 2026 at 5:47 pm

    Will be significantly faster putting all that into a single query with a JOIN clause.

    <?php
    $table_sql = "SELECT q.* 
                  FROM participation AS p
                      INNER JOIN qpons AS q ON p.qpon_id = q.id
                  WHERE shop_id = '{$session->user_id}'";
    while ($row = $database->fetch_array($result)) {
        $qpons[] = array (
            'id'                    => $row['id'],
            'service'       => $row['service'],
            'start_date'    => $row['start_date'],
            'end_date'      => $row['end_date']
        );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing a homework project that requires this: Below you will find the code
The code below will validate required fields within currently visible fieldsets, but only if
The code below will find an image if it exists and move it above
I have a piece of code which will find out the repeating elements in
Below you will find my function for the uploadAction. This code works. I am
I have the code below that will open a modal window. This works in
Below you will find my current vHost entry that I am using for a
thanks for taking the time to stop by my question. Below you will find
The code below will report Syntax error message: type 'a edge = |Empty |End
My script below will use two external tables to fill two separate tables, but

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.