Page 1 of 1

Help I am confused about how to get a inventory system going

Posted: Thu Dec 14, 2006 4:27 am
by Mythic Fr0st
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Well, my game is coming along well, but the next part I am really struggling with is inventory, I usually can think of ways to do things, but this im not sure

(basically, you start off with a dagger & and a spell, which you can buy others from the shop)

so im not sure how to do this because, i've dont even know if its possible to have string arrays in MySQL

(probably is but I dont know) anyway, this is what i've currently got...

Code: Select all

<php
foreach ($inv as $key => $shw)
{
$ihtw='<option value='.$inv[$key].'>'.$inv[$key].'</option>';
echo $ihtw;
}
?>
</select>
</form>
and no it doesnt work... I just see $inv[$key] and so on, could I get some help plz (it'd be good if I could be told how to make arrays in MySQL)

I did notice once there was something called 'index' does that have anything to do with it


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Dec 14, 2006 4:33 am
by s.dot
$ihtw='<option value='.$inv[$key].'>'.$inv[$key].'</option>';
Should be

Code: Select all

$ihtw = '<option value='.$key.'>'.$key.'</option>';
If you need to store an array into MySQL, you can use the serialize() function on it to turn it into a string. Then when you pull the serialized array from MySQL, you can get it back into an array by using unserialize().