Well first im not a noob at php but not an expert either but it is my first time making a game from php :xbones: but im kinda stuck 😕 first off i made a armor shop and made the form for it but its making it update the database. i need it to update the database for armor, subtracting the gold for the armor and also adding how much defense is on the armor. here is the armorshop.php page im not really sure on making the armorshop2 page tho 😕 i need it to also go back to armorshop.php page and says that they now own that armor..
armorshop.php
<center>
<?php
include 'db.php';
$sql = mysql_query("SELECT * FROM users WHERE user_name = '".$_SESSION['user_name']."'");
while ($row = mysql_fetch_array($sql)) {
if (($_SESSION['user_level'] == 1) || ($_SESSION['user_level'] == 2) || ($_SESSION['user_level'] == 3) || ($_SESSION['user_level'] == 4) || ($_SESSION['user_level'] == 5)) {
echo '<font class="txt">You have Gold: '. $row["gold"] .' and Money '. $row["money"] .'</font>';
}
}
?>
<?php
include 'db.php';
$sql = mysql_query("SELECT * FROM users WHERE user_name = '".$_SESSION['user_name']."'");
while ($row = mysql_fetch_array($sql)) {
?>
<br><br>
<font class="txt">
<form name="armor" method="post" action="../index.php?pages=armorshop2">
<table width="317" border="1" cellpadding="0" cellspacing="0" class="txt">
<tr>
<td width="21"></td>
<td width="123">Armor Name</td>
<td width="60">Att/Def</td>
<td width="113">Cost</td>
</tr>
<tr>
<td><?php
include 'db.php';
$gold = $row['gold'];
if ($gold >= 50) {
echo'<input name="armor" type="radio" value="shield">';
}else{
echo ' ';
}
?></td>
<td>Shield</td>
<td>0/5</td>
<td>5 gold</td>
</tr>
<tr>
<td><?php
include 'db.php';
$gold = $row['gold'];
if ($gold >= 100) {
echo '<input name="armor" type="radio" value="leatherhelmet">';
}else{
echo' ';
}
?></td>
<td>Leather Helmet</td>
<td>0/5</td>
<td>10 gold</td>
</tr>
<tr>
<td><?php
include 'db.php';
$gold = $row['gold'];
if ($gold >= 100) {
echo '<input name="armor" type="radio" value="bodyguard">';
}else{
echo' ';
}
?></td>
<td>Body Guard</td>
<td>0/10</td>
<td>25 gold</td>
</tr>
<tr>
<td><?php
include 'db.php';
$gold = $row['gold'];
if ($gold >= 100) {
echo '<input name="armor" type="radio" value="steelarmor">';
}else{
echo' ';
}
?></td>
<td>Steel Armor</td>
<td>0/25</td>
<td>50 gold</td>
</tr>
</table>
<table width="317" border="1" cellpadding="0" cellspacing="0" class="txt">
<tr>
<td><center><input name="armor" type="submit" value="Buy Armor" class="submit-button"></center></td>
</tr>
</form>
</font>
</center>
<?php
}
?>
Can someone help me please
Thank you
Smackie