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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:04:52+00:00 2026-05-28T18:04:52+00:00

As a self-taught (poorly) PHP coder, I have exhausted all the trial-and-error possibilities so

  • 0

As a self-taught (poorly) PHP coder, I have exhausted all the trial-and-error possibilities so I humbly ask your help for a small problem I have been having while coding a community online “bidding” game.

I have two tables in my DB – one, called DCO_sponsors, listing a list of IDs, an associated amount of (virtual!) money, an availability counter and (if they are already associated with a team), the team’s id.

Structure: id, amount, available, team_id

The second table, DCO_bids, lists the team’s “bids” to clinch the above mentioned sponsors. It includes a bid id, the team id, a “part_b” which in this case is the sponsor id (the same table is used by other processes), a concept field where the kind of bid is described (e.g. “sponsorship”) and finally two fields for the bid amount and the current status (A for active, W for waiting/pending, etc).

Structure: id, team_id, part_b, concept, bid, status

What I want to achieve is the site to show me (the admin) a list of all the sponsors in the DCO_sponsors table, ordered by the amount, and next to it the team_id of the team which bid the highest for it (teams only get four “sponsors” and get the highest grossing first, so it’s important I see them in order of amount).

The code I produced, and that I hoped it would work, is as follows:

            echo "<table>";
        echo "<tr><th width=30>Id</th><th width=100>Amount</th><th width=220>Team</th><th width=100>Offer</th><th></th><th></th><th></th></tr>";

        $data = mysql_query("SELECT id, amount FROM DCO_sponsors WHERE available='1' ORDER BY amount DESC", $CONNECTW);
        while($row=mysql_fetch_row($data))
        {
            $sp_id = "$row[0]";
            $sp_amount = number_format($row[1]);

            $teamdata = mysql_query("SELECT team_id, bid FROM DCO_bids WHERE concept='sponsorship' AND part_b='$sp_id' ORDER BY bid DESC", $CONNECTW);
            while($row=mysql_fetch_row($teamdata))
            {
                $team_id = "$row[0]";
                $team_bid = number_format($row[1]);                     
            }               

            // I call the name of the team from another table

            $teamlabel = mysql_query("SELECT completename FROM DCO_teams WHERE id='$team_id'", $CONNECTW);
            while($row=mysql_fetch_row($teamdata))
            {
                $teamname = "$row[0]";                      
            }

            echo "<tr><td>$sp_id</td><td>&pound;$sp_amount</td><td>$teamname</td><td>$team_bid</td><td><a href='$RKP/kernel/lib/php_lib/action/AC_Bids_Update.php?op=A1&item_id=$item_id'><div id='IC_Tick' title='Sign Round 1 deal with $teamname'></div></a></td><td><a href='$RKP/kernel/lib/php_lib/action/AC_Bids_Update.php?op=A2&item_id=$item_id'><div id='IC_Tick' title='Sign Round 2 deal with $teamname'></div></a></td><td><a href='$RKP/kernel/lib/php_lib/action/AC_Bids_Update.php?op=A3&item_id=$item_id'><div id='IC_Tick' title='Sign Round 3 deal with $teamname'></div></a></td></tr>";

        }

        echo "</table>";

The links in the last cells of the row are tick-boxes linked to actions that modify other tables.

At the moment, the result I get is the list of the sponsors ordered by the amount (as it should be), but the team name appearing alongside it is the same for all rows, it’s NOT the one of the highest bidder and the bid amount is NOT the one of the highest bidder but simply the first one to put one in.

I spent the best part of the last three nights trying to work out where I am getting this wrong… I hope you can help!

  • 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-28T18:04:53+00:00Added an answer on May 28, 2026 at 6:04 pm
    <table>
      <tr>
        <th width=30>Id</th>
        <th width=100>Amount</th>
        <th width=220>Team</th>
        <th width=100>Offer</th>
        <th></th>
        <th></th>
        <th></th>
      </tr>
    <? $data = mysql_query("SELECT id, amount FROM DCO_sponsors WHERE available='1' ORDER BY amount DESC", $CONNECTW); ?>
    
    <? while($row=mysql_fetch_row($data)):
        $sp_id = $row['id'];
        $sp_amount = number_format($row['amount']);
    
        $teamdata = mysql_query("SELECT team_id, bid FROM DCO_bids WHERE concept='sponsorship' AND part_b='$sp_id' ORDER BY bid DESC", $CONNECTW);
        while($row=mysql_fetch_row($teamdata))
        {
            $team_id = $row['id'];
            $team_bid = number_format($row['bid']);                     
        }               
    
            $teamlabel = mysql_query("SELECT completename FROM DCO_teams WHERE id='$team_id'", $CONNECTW);
            while($row=mysql_fetch_row($teamlabel))
            {
                $teamname = $row['completename'];                      
            }
    ?>
        <tr>
          <td><?=$sp_id;?></td>
          <td>&pound;<?=$sp_amount;?></td>
          <td><?=$teamname;?></td>
          <td><?=$team_bid;?></td>
          <td><a href='<?=$RKP;?>/kernel/lib/php_lib/action/AC_Bids_Update.php?op=A1&item_id=<?=$item_id;?>'>
            <div id='IC_Tick' title='Sign Round 1 deal with <?=$teamname;?>'></div></a></td>
          <td><a href='<?=$RKP;?>/kernel/lib/php_lib/action/AC_Bids_Update.php?op=A2&item_id=<?=$item_id;?>'>
            <div id='IC_Tick' title='Sign Round 2 deal with <?=$teamname;?>'></div></a></td>
          <td><a href='<?=$RKP;?>/kernel/lib/php_lib/action/AC_Bids_Update.php?op=A3&item_id=<?=$item_id;?>'>
            <div id='IC_Tick' title='Sign Round 3 deal with <?=$teamname;?>'></div></a></td>
        </tr>
    
    <? endwhile; ?>
    </table>
    

    Your issue came into play with your last while call. You were attempting to mysql_fetch_row($teamdata) again instead of $teamlabel.

    Also, as a rule, you should just write out any html that doesn’t need to be generated by php. So I broke that stuff out for you.

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

Sidebar

Related Questions

I'm a self-taught developer and my experience is all in small applications that I've
As a mostly self-taught programmer, I have never really had anyone explain why certain
I have been in web programming for 2 years (Self taught - a biology
I've taught myself Obj-C, and have been self-teaching Cocoa, but adding Core Data to
I'm a self-taught developer and, quite frankly, am not all that great at figuring
I have only recently started programming significantly, and being completely self-taught, I unfortunately don't
I am a self taught PHP programmer. So I've never taken any Computer Science
I'm a self-taught coder and I like to debug by echoing suspicious variables and
I am a self-taught computer programming enthusiast. I have learn C, quite a bit
I have 2 1/2 years experience of VB.Net, mostly self taught, so please bear

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.