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 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

Ask A Question

Stats

  • Questions 453k
  • Answers 453k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer These are called processing instructions. Add 'em using XmlDocument.CreateProcessingInstruction. May 15, 2026 at 9:33 pm
  • Editorial Team
    Editorial Team added an answer first result on google for "structuremap lifecycle": http://structuremap.github.com/structuremap/Scoping.htm "PerRequest" is… May 15, 2026 at 9:33 pm
  • Editorial Team
    Editorial Team added an answer I would really suggest have separate regression tests and unit… May 15, 2026 at 9:33 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.