I have a shop for a game where you use fake money to buy items. I have made it so users can check off the items they want with the checkboxes. Once they hit submit they are able to see the total cost and the total ammount of items they bought. The problem is I want to figure out how to print something like. You bought the following items: 1 potion 1 sword. After this I would need to insert 1 more potion and 1 more sword into their inventory in the database.
Here is my code. If you have any questions please ask because I have been working on this for days.
<?
session_start();
$Location="Main Item Shop";
include("background.html");
if(empty($data['Username'])){print"You must be logged in to view this.<br><a href=\"Login.php\">Login</a>";}
else{
//select database********************************************
$user="******";
$pass= "******";
$db="******";
$link = mysql_connect( "localhost", "$user", "$pass" );
if ( ! $link )
die( "Couldn't connect to MySQL");
mysql_select_db( $db)
or die ( "Couldn't open $db: ".mysql_error());
//check information******************************************
$result = mysql_db_query(rpg, "SELECT Name,Price FROM items order by Price desc" );
if(!($result)) {
print "Useronline Select Error > ";
}
echo "<table border=\"0\">";
echo"<tr>";
echo"<td width=\"142\"><b>Item</b></td>";
echo"<td width=\"185\"><b>Price</b></td>";
echo"<td width=\"142\"><b>Select</b></td>";
echo"</tr>";
while ($row = mysql_fetch_assoc($result)) {
echo"<tr>";
echo"<form name=\"items\" method=\"post\" action=\"\">";
echo "<td>$row[Name]</td>";
echo "<td>$row[Price]</td>";
echo"<td><input type=\"submit\" name=\"Submit\" value=\"buy\"></td>";
}}
echo"</td></tr></form>";
echo"You just bought a $submit";