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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:28:34+00:00 2026-06-07T04:28:34+00:00

I am creating an inventory system for Magic the Gathering Cards and need to

  • 0

I am creating an inventory system for Magic the Gathering Cards and need to update the prices with the main card info.

I have two tables, Cards and Prices

Cards has the following columns:
ID, Name, Ed, Price

Prices has the following columns:
Name, Ed, Price

I need Cards.Price to be replaced with the value in Prices.Price.

Below is the code for two different attempts to make this work (I know I am probably making this a lot harder than it needs to be….)

Attempt #1

    $query = "SELECT * FROM Cards";

    $result = mysql_query($query) or die(mysql_error());
    $row = mysql_fetch_array($result) or die(mysql_error());

    while($row = mysql_fetch_array($result))
    {
    $name=$row['Name'];
    $ed=$row['Ed'];

    $queryb = "SELECT Price FROM Prices WHERE Name='".$name."' AND Ed='".$ed."'";
    $resultb = mysql_query($queryb) or die(mysql_error());
    $rowb = mysql_fetch_array($resultb) or die(mysql_error());
    $newPrice = $rowb['Price'];
    mysql_query("UPDATE Cards SET Price='".$newPrice."'");
    }

Attempt #2

    $queryCards = "SELECT * FROM Cards";
    $queryPrices = "SELECT * FROM Prices";
    $dblink = mysql_connect($dbhost, $dbuser, $dbpass);
    mysql_select_db($dbname, $dblink);


    $resultCards = mysql_query($queryCards) or die(mysql_error());
    $resultPrices = mysql_query($queryPrices) or die(mysql_error());
    $rowCards = mysql_fetch_array($resultCards) or die(mysql_error());
    $rowPrices = mysql_fetch_array($resultPrices) or die(mysql_error());



    if ($rowCards['Name']==$rowPrices['Name'] && $rowCards['Ed']==$rowPrices['Ed'])
    {
    $newPrice = $rowPrices['Price'];
    mysql_query("UPDATE Cards SET Price='".$newPrice."' WHERE
    Name='".$rowCards['Name']."' AND Ed='".$rowCards['Ed']."'"); 
    }
    while($rowPrices = mysql_fetch_array($resultPrices))
       {
       if ($rowCards['Name']==$rowPrices['Name'] && 
                    $rowCards['Ed']==$rowPrices['Ed'])
          {
          $newPrice = $rowPrices['Price'];
          mysql_query("UPDATE Cards SET Price='".$newPrice."' WHERE 
                       Name='".$rowCards['Name']."' AND Ed='".$rowCards['Ed']."'");
          }  
       }       

   $rowPrices = mysql_fetch_array($resultPrices) or die(mysql_error());

   while($rowCards = mysql_fetch_array($resultCards))
   {
   while($rowPrices = mysql_fetch_array($resultPrices))
       {
       if ($rowCards['Name']==$rowPrices['Name'] &&
                $rowCards['Ed']==$rowPrices['Ed'])
            {
            $newPrice = $rowPrices['Price'];
                mysql_query("UPDATE Cards SET Price='".$newPrice."' WHERE 
                     Name='".$rowCards['Name']."' AND Ed='".$rowCards['Ed']."'");
                }  
                }      
    }
  • 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-07T04:28:36+00:00Added an answer on June 7, 2026 at 4:28 am
    UPDATE Cards 
       JOIN Prices ON Cards.Name = Prices.Name AND Cards.Ed = Prices.Ed 
    SET Cards.Price = Prices.Price
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a game, and am currently working on the Inventory system for it.
So basically I'm working on creating a inventory/sales system. I'm using Core Data, and
I'm creating a small car dealership website, and on my inventory page I need
I am currently creating an MVC3 application using Ninject. I have two controllers which
I'm creating a UML Class Diagram for an inventory system as part of a
Let me explain, take an inventory system. You have items and you have rooms.
Creating a voting system just like stackoverflow. Questions like this have been asking several
I have been looking into creating a custom mySQL Point Of Sales system so
I have a stored procedure for creating inventory transactions that requires the assembly of
Creating liquid layouts is an immense pain. Now, I totally understand that tables should

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.