Jump to content

Could use some help


Raven25

Recommended Posts

Image :  http://i1362.photobucket.com/albums/r697/ricky_rosa1/Game_zps9a5a45f6.png

The code below trying to make

echo "<td><a href=$PHP_SELF?action=buy&amount=1&gem=$i&price=$buyprice>Buy 1</a></td>";
 echo "<td><a href=$PHP_SELF?action=sell&amount=1&gem=$i&price=$buyprice>Sell 1</a></td>";

which you can see from the image into a Input where users can input whatever amount they want to buy or sell. With it those two line codes connect to the 5 items as its set up that way  so the input box cant effect that the code for the complete transaction has to connect to them  so if a user puts in 2 for each box the complete transaction button will know they bought a total of 10 items and it needs to know if its a buy or a sell  that the user is asking as well as  in case  a user puts 1  for one item in buy and a 5 in sell for a item itll know that transaction.  But i dont know how to do that lol  I hope someone can help

* it cant effect the layout meaning ruining it.....so the box  for input has to replace Buy 1/Sell 1*






$gemname=$stockdata[gemname][$i];
         $saleprice=ceil($stockdata[baseprice][$i]*(1+$spread));
         $buyprice=ceil($stockdata[baseprice][$i]*(1-$spread));
         $amount=$stockdata[amount][$i];
         echo "<tr><td align=center>$gemname</td><td align=center>$saleprice</td><td align=center>$buyprice</td>";
         if ($playerinfo[status]==5) echo "<td align=center>$amount</td>";
         echo "<td><a href=$PHP_SELF?action=buy&amount=1&gem=$i&price=$buyprice>Buy 1</a></td>";
         echo "<td><a href=$PHP_SELF?action=sell&amount=1&gem=$i&price=$buyprice>Sell 1</a></td>";
         echo "<td>$amount</a></td>";
         echo "</tr>";
      }
      echo "</table>";
   echo('  <p><center><input name="Submit" type="button" value="Complete Transaction" class="button" /></center></p>');

Link to comment
Share on other sites

So you want to allow the player/user to input the quantities they want to buy or sell for each item?
 
You can change the links to input fields using the following

echo "<td><input type=tet name=\"gem[$i][buy]\" value=\"\" maxlength=\"3\" size=\"3\" /></td>";
echo "<input type=tet name=\"gem[$i][sell]\" value=\"\" maxlength=\"3\" size=\"3\" /></td>";

Now in the code that processes the form you'll do something like

if(isset($_POST['Submit'])) {
	if(is_array($_POST['gems'])) {
		foreach($_POST['gems'] as $gem_id => $amount)
		{
			$buy_qty  = $amount['buy'];    // the quantity to buy
			$sell_qty = $amount['sell'];   // the quantity to sell

			// your code to process gem order here
		}
	}
}
Edited by Ch0cu3r
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.