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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:33:55+00:00 2026-06-02T02:33:55+00:00

I will make this as short and descriptive as possible (considering my case is

  • 0

I will make this as short and descriptive as possible (considering my case is way longer).
Lets say I have 2 database tables with the following structures:

User table:

id —- username—- gold

Items table:

id—– item_name—- item_price

What I am trying to achieve is brainstorming, I tried this with over 20 script combinations. I need to be able to echo out all items in the table to a good layout (done)
Have a text box for the user to type in the value required to be bought.
an a href to submit the amount, deduct the price of the item from the amount of gold the user has, then add 1 to the inventory. I am not requiring php code, as it is easy. All I need is help with trying to update the value typed in “Live”. The layout of the “shop” will look something like this:

while($_row = mysql_fetch_assoc($query)){
 echo out name...
 <input type = 'text' name = 'to_buy_value'/>
 <a href = 'javascript:;' class = 'buy'>Buy</a>
}

I hope the above code gives you enough reference.
TL;DR (after db structure?)
1- A text box with an a href as the submit.
2- table update is done on-the-fly (no reloads). Ajax.
3- Be able to buy more than 1 item at a time without page reloads
4-no help with php code required unless necessary.
I’d appreciate any sort of 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-06-02T02:33:56+00:00Added an answer on June 2, 2026 at 2:33 am

    Here’s a very rough solution for you. In your while loop you could attach the item’s database id to the id of the element:

    while($_row = mysql_fetch_assoc($query)){
     echo out name...
     <input id="purchaseAmount{$_row->id}" type="text" name="value_to_buy" />
     <a id="purchaseButton{$_row->id}" href="#" class="buy">Buy</a>
    }
    

    Then bind a javascript function to your “Buy” link which will make an AJAX request:

    $('.buy').bind('click', function() {
    
      // Grab the item id and amount
      var itemId = $(this).attr('id').substring(14);
      var itemAmount = $('purchaseAmount' + itemId).val();
    
      $.ajax({
        url: 'someurl/purchaseItem.php',
        data: { item: itemId, amount: itemAmount },
        success: function(data) {
          // Update the player's gold and inventory on screen
        }
      });
    });
    

    The “purchaseItem.php” file could return a simple JSON object that holds the player’s current gold and item amount for the inventory. Or you could return HTML, depending on how your page is setup.

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

Sidebar

Related Questions

I will do what I can to make this short and sweet. I have
I will make this quick and simple I have a query and I want
Hopefully this explanation will make sense, but what is the best way (if it
To make this short, I will show what I need exactly. Here is the
I will keep this very short: I'm trying to make a loop through an
How do you sort an array of strings in C++ that will make this
I will make this quick. I'm using Ruby/LDAP to search using my base_dn criteria.
I will try to make this as clear as I can, but if you
Consider the following code: $(a).attr(disabled, disabled); In IE and FF, this will make anchors
Ho to make this simple xml with php using DOM? Full code will be

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.