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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:16:46+00:00 2026-05-12T06:16:46+00:00

Here’s what I’ve got so far- $awards_sql_1 = mysql_query(‘SELECT * FROM categories WHERE section_id

  • 0

Here’s what I’ve got so far-

$awards_sql_1 = mysql_query('SELECT * FROM categories WHERE section_id = 1') or die(mysql_error());
$awards_sql_2 = mysql_query('SELECT * FROM categories WHERE section_id = 2') or die(mysql_error());
$awards_sql_3 = mysql_query('SELECT * FROM categories WHERE section_id = 3') or die(mysql_error());
$awards_sql_4 = mysql_query('SELECT * FROM categories WHERE section_id = 4') or die(mysql_error());

$loop = 1;

while($row_sections = mysql_fetch_array($sections_query)) {
    $category = 1;
    echo "<h3>" . $row_sections['section_name'] . " (Loop# $loop)</h3>";

    while($categories = mysql_fetch_array(${"awards_sql_{$loop}"})) {
        ${"winners_sql_{$loop}"} = mysql_query("SELECT * FROM 2009_RKR_bestof WHERE section = $loop && category = $category ORDER BY result_level ASC") or die(mysql_error());
        echo "<h4><strong>{$categories['category_name']}</strong></h4>";
        echo "<ul class=\"winners\">";
>>          while($winners = mysql_fetch_array(${"winners_sql_{$loop}"})) {
                switch ($winners['result_level']) {
                    case 1: $result_level = "Platinum"; break;
                    case 2: $result_level = "Gold"; break;
                    case 3: $result_level = "Silver"; break;
                }
                if (isset($winners['url'])) { $anchor = "<a href=\"http://{$winners['url']}\" target=\"_blank\">"; $close = "</a>"; }
                echo "<li>$anchor{$winners['winner']}$close ($result_level)</li>";

                unset($anchor);
                unset($close);
            }
        echo "</ul>";
        $category++;
    }
    $loop++;
}

Where I’m getting stumped, is I’m getting this thing to loop through correctly, my loop counter ($loop) is working, but when it gets time to spit out the actual reward recipients after the first loop through winners, it’s only producing the category titles, the list-items are not getting looped out.

I added a little pointer to where I think the problem begins or centers around (>>).

My guess is I need to maybe unset a var somewhere, but I don’t know, I can’t see it.

  • 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-12T06:16:47+00:00Added an answer on May 12, 2026 at 6:16 am

    I’m with KM – you’re displaying a single page and with your loops, you’ve got a LOT of queries happening at once – what if 1,000 people hit that page at the same time? ouch…

    Maybe consider a larger query (with some repeated data) and loop through it once?

    For example:

    SELECT 
      section_name, 
      category_name,
      result_level,
      url,
      winner
    FROM 2009_RKR_bestof
    INNER JOIN categories ON 2009_RKR_bestof.category = categories.id
    INNER JOIN sections ON 2009_RKR_bestof.section = sections.id
    ORDER BY section_name,category_name ASC
    

    In your loop, you can do checks to determine if you’re in a new section (category/whatever):

    //pseudo-code
    $current_section = "";
    while($stuff = mysql_fetch_array($sql))
    {
      if ($current_section == "")
      {
        $current_section = $stuff["section_name"];
      }
      if ($current_section == $stuff["section_name"])
      {
        //keep going in your loop
      }
      else
      {
        //we've gotten to a new section - so close your html and start a new section
      }
    }
    

    You get the idea..

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

Sidebar

Related Questions

I'm getting an error here that says I haven't defined a method, but it
This is beyond both making sense and my control. That being said here is
IE is giving me an undefined NAN when i try to view the calender...
I would like to remove/delete a migration file. How would I go about doing
I am writing a query to fetch results for all the values in a
Let say I have the following desire, to simplify the IConvertible's to allow me
There doesn't seem to be any tried and true set of best practices to
I have found this example on StackOverflow: var people = new List<Person> { new

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.