little help with php

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
kierongi
Posts: 30
Joined: Mon Aug 12, 2013 9:57 pm

little help with php

Post by kierongi »

just a quick question guys:

lets say for instance i buy 5 health potions

and i want to set a limit of 5 item in the inventory

i have tried to use statements such as:

if ('inventory' > 5)
{
echo "Your items list is full either use or sell to make this purchase";
echo "<center><a href='index.php'>Go Back</center></a>";
exit;
}

but this is not working i am sure that i will either have to add a counter into the database or something like that
Last edited by kierongi on Fri Aug 30, 2013 8:20 pm, edited 1 time in total.
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: Limit a item (PHP)

Post by vitinho444 »

When you buy a potion, do you add it to the inventory right?
so just do:

Code: Select all

if(iventory["potions"] > 4)
{
//players has 5 potions or more
}
 
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
kierongi
Posts: 30
Joined: Mon Aug 12, 2013 9:57 pm

Re: Limit a item (PHP)

Post by kierongi »

cheers vitinho444 had to add another query for it to work
Post Reply

Return to “Beginner Help and Support”