/    Sign up×
Community /Pin to ProfileBookmark

hi guys im currenly neally completion on my online game and wounderd how i could go about doing this. it is a game shop were my users can sell any iteams they have(theres only 2) and then on the page the user can type how many they want to sell and how much are they selling it for and then on the buy page it is a simple list of what the iteam is and how much money it costs.

i have difficulty making it, but hope someone can help me out looking at my code.

the basic behind this is each user has 2 items witch are thease(all thease feilds are numbers)

[code=php]
$user[weapon]
$user[secondweapon][/code]

and there money is kept in the field

[code=php]$user[money][/code]

this is how users are got:

[code=php]$user = MYSQL_QUERY(“SELECT * from users WHERE id=’$_COOKIE[id]’ AND password = ‘$_COOKIE[pass]'”);
$user = mysql_fetch_array($user);[/code]

this is a peice of code taken from a page which ive editied and can be used in the updating a users feild by a certain amount (eg. +1 weapon) :

[code=php]mysql_query(“UPDATE users SET money=money-‘$need_money’, weapon=weapon+’1′ WHERE id=’$user[id]'”);[/code]

and if it helps this is how it gets infomation from another user(taken from my profile script)

[code=php]
if (!$_GET[user])
{
$getuser = mysql_query(“SELECT * from users”);
echo (“<table width=”100%” border=”0″ cellpadding=”5″ cellspacing=”0″>
<tr>
<td>”);
while ($user = mysql_fetch_array($getuser))
{
// gets all the users information.
echo (“<a href=”members.php?user=$user[username]”>$user[username]</a><br />n”);
// links to a page to view the user’s profile.
}
echo (“</td>
</tr>
</table>”);
}
else
{
$getuser = mysql_query(“SELECT * from users where username = ‘$_GET[user]'”);
$usernum = mysql_num_rows($getuser);
if ($usernum == 0)
{
echo (“User Not Found”);
}
else
{
$profile = mysql_fetch_array($getuser);
echo (“<table width=”100%” border=”0″ cellpadding=”5″ cellspacing=”0″>
<tr>
<td><center><b>$profile[username]’s profile:</b><br /></center>
<center><img src=’uploaded_files/$profile[image_location]’ /><br /></center>
Location: $profile[location]<br />
Email: $profile[email]<br />
Points: $profile[score] points<br />
Awards: $profile[awards]<br />
</td>
</tr>
</table>”);
// in the above code, we display the user’s information.
}
}[/code]

if you have no idea what im on about please reply, as i realy want to get this to work.
if you help me i will send you a big cake?

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @mitchell spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...