PHP - Help Needed Please.

Brentatechnologies's Avatar, Join Date: Aug 2011
Go4Expert Member
hey there,

Been a while since I posted on the forums...I have been working on a project for school...
and so far it's coming along nicely, but, I have run into a problem...

I'd like to create a drop down list with php and send the data selected from the drop-down to a database in which i've made...That's just one problem


Second problem...
Where would I start with creating an item database...I'll start off small a list of 50 items available to "buy" from a "market"


Third Problem...
I'd like to make a combat/stat system but once again no idea where to start...

This is a text-based game turn based (still to implement turn base) and you can view what I have done at

unitedsticks.bugs3.com
0
pein87's Avatar
Ambitious contributor
Create a while loop and place the values needed. Ok so lets say you have a database with the fields

item_id, item_name

you'd need to fetch an array of the dataset and display it

PHP Code:
echo "<select>";
while((
$arr mysql_fetch_assoc($result)) !== null)
{

echo 
"<option value=\"$arr['item_name']\">" $arr['item_name'] . " </option>";

}

echo 
"</select>"
Its important to not put the select tags in the loops output or you'll get an ugly surprise. Instead the loop serves to print an option for each result that exits in that table. Hope this gets you started. I assume you know how to connect to a database etc...