A game in PHP

Suggest any tutorials you would find useful.

A game in PHP

Postby princelvis » Fri Mar 05, 2010 7:16 am

A game like Mafia Wars in Facebook.

can you just give me sample of a simple game where a user can buy something and automatically reduce his money. Thank you in advance.
princelvis
 
Posts: 1
Joined: Wed Feb 10, 2010 10:37 am
Online: 0s
Karma: 0

Re: A game in PHP

Advertisment

Advertisment
 

Re: A game in PHP

Postby wide_load » Fri Mar 05, 2010 11:25 am

No we are not going to make anything for you that's not really how it works.
Image
User avatar
wide_load
Top Contributor
 
Posts: 5617
Joined: Thu Aug 13, 2009 1:04 pm
Online: 13d 22h 9m 34s
Karma: 45

Re: A game in PHP

Postby bowersbros » Fri Mar 05, 2010 4:35 pm

We WONT give code. But we WILL help you code it.

Questions:
1) How far have you got in coding it yet?
2) Do you know the Facebook API?


if the answer to either is no, then please state what you want to know how to do, and we will try out best to help you.

Answer:
You want to be able to lower money from them if they buy something,

Now assuming your storing the prices and money etc. in database (you should do this), This is quite a simple task.

I will assume two tables are used.

Table 1:
name: items
fields:
id (int(11) AI PK)
name (varchar(255)
price (float(6,2))

Table 2:
name: users
fields:
id (int(11) AI PK)
name (varchar(255)
credit(float(6,2)
pass (varchar(32))

then from there, you will select an items cost via its id from the items table

eg:

$query1 
mysql_query("SELECT price FROM items WHERE id=1");
$result mysql_result($query1,0);
 


from there, you need to take that price away from the users credit:

eg:

$query2 
mysql_query("INSERT INTO users SET credit=(credit-$result)");
 


That should work.
The early bird catches the worm but the second mouse gets the cheese!

If you look like your passport picture, you probably need the trip.

---

IM contact details:
Example doesnt work, requires a href
bowersbros
Top Contributor
 
Posts: 2019
Joined: Tue Apr 21, 2009 7:55 pm
Location: United Kingdom
Online: 4d 10h 49m 56s
Karma: 6


Return to Tutorial Suggestions

Who's online?

Users browsing this forum: No registered users and 1 guest