Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2013
    Posts
    2

    Unanswered: Displaying table data with input field.

    Hello people, i've stumbled across a problem while learning that i can't seem to solve. In my MySQL database tables i have "name" and "coins" and on my page i have an input box, where you type a name, and the site should show how many coins he has. The problem is i can't find out how to that, and i would really appreciate if some of you in here could help me.

    Thanks in advance.

    my database http://i37.tinypic.com/amwo7l.png

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so what are you using to interact with the MySQL server
    ...
    it could be you are using AJAX so are issuing an asynchronus request tot eh server to count the number of coins for that user. if so have you worked out where the problem lies
    it could be:-
    the request is invalid (either its not being sent or its invalid SQL
    the server is returning the correct information but your frontend isn't correctly populating the display fiels


    or if you are using the more classical web design you need to process the person id to retrieve details for them
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2013
    Posts
    2
    Hello this is the basic form thats basicly just a input field and a button in PHP


    PHP Code:
    <form method="post" action="<?php echo $PHP_SELF;?>">
    Ingame name:<input type="text" size="12" maxlength="12" name="coins"><br />
    <input type="submit" value="Check Balance" name="submit"><br />
    </form><br />

    <?php
    From here i need it to take that name and then look through the database and find the amount of coins the desired user has.



    This is the mysql thingy the problem is, that this just takes the first user and shows hes coins, and i cant seem to find out how to make it like i want.
    PHP Code:
    <?php
    // Make a MySQL Connection
    mysql_connect("localhost""root""******") or die(mysql_error());
    mysql_select_db("coinsdb") or die(mysql_error());

    // Retrieve all the data from the "example" table
    $result mysql_query("SELECT * FROM users")
    or die(
    mysql_error());  

    // store the record of the "example" table into $row
    $row mysql_fetch_array$result );
    // Print out the contents of the entry 

    echo "Coins: ".$row['coins'];

    ?>
    Thanks for the interest

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    So you are using plain vanilla PHP, so its not really a MySQL problem after all

    in vanilla PHP the process is:-
    have a form
    submit the form
    handle any user input
    display a new php page (whether thats the same page or a new page is up to you

    https://www.google.co.uk/#hl=en&gs_r...w=1920&bih=995
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •