1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP - Help Needed Please.

Discussion in 'PHP' started by Brentatechnologies, Feb 20, 2012.

  1. Brentatechnologies

    Brentatechnologies New Member

    Joined:
    Aug 22, 2011
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. pein87

    pein87 New Member

    Joined:
    Aug 6, 2010
    Messages:
    173
    Likes Received:
    47
    Trophy Points:
    0
    Occupation:
    Web Dev
    Location:
    Limbo
    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:
    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...
     

Share This Page