Jump to content

Ph0enix

Members
  • Posts

    64
  • Joined

  • Last visited

    Never

Posts posted by Ph0enix

  1. Well its sort of working.
    When i put this code in it works showing the points for users..

    $result = mysql_query("SELECT `points` FROM `points`") or die(mysql_error());
    echo "<select name='names'>";
    while($row = mysql_fetch_assoc($result)) {
    echo "<option value='$row[points]'>$row[points]</option>";
    }
    echo "</select>";

    (the table is called points)

    but when i try this code it comes up with the right amount of options but they all say Array[user_name]


    $result = mysql_query("SELECT `user_name` FROM `points`") or die(mysql_error());
    echo "<select name='names'>";
    while($row = mysql_fetch_assoc($result)) {
    echo "<option value='$row[user_name]'>$row[user_name]</option>";
    }
    echo "</select>";

    Do you know whats wrong?
  2. Hi, i want to make a drop down menu that has thigs from my database in it.
    I have people registering on my website so it is annoying to add them in on my own.
    So how would i get everybody user_name into a drop down menu. Please help! thanks
  3. wow theres a lot of stuff there. Thanks
    But i find things easier to take in if you could tell me and give me an example cause im a noob.
    [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]PHP Newbie Help[/quote]
    Could you explain it please?
  4. Hi, i know how to select a row of data by using this: $sql = "SELECT * FROM table ORDER BY id DESC";
    But how do i select a whole column, so i would have the users name and their information.
    And i would like for it to be displayed just simple like this:

    Ph0enix England 14/03/1990 Male.

    Could anyone help me to do this please?
    Thanks
  5. Ok i have to problems and i would really appreciate any help with these.

    1) I'm making a gaming league and i would like people to report games when they have won.
    I know how to make a HTML form but then when i send the info to a php script how do i turn the information into variables so i can use then further down in the script.

    2) My second problem is that when people report a game i would like 5 points to be added to the points but i cant do it. I dont get an error but the script just doesnt work.. This is my script.

    [code]

    $name = "Ph0enix";
    $db = mysql_connect("HOST", "USERNAME" , "PASSWORD");
    mysql_select_db('DBNAME');
    mysql_query("UPDATE points SET points = points + 5 WHERE user_name= $name");

    [/code]

    Can anyone please tell me what im doing wrong and help me!

    Thanks!
  6. Ok i dont know much on php so i probably wont help a lot, but when iv used a webhost and created a database it has given me the server name. so for example im using freehostia so the servername they gave me was mysql2.freehostia.com. My username is Ph0enix and my password is Ph0enix2 and my database is Ph0enix_db. so when im connecting to my database i would put
    [code]<?php

    mysql_connect("mysql2.freehostia.com","Ph0enix","Ph0enix2") or die ("Unable to connect to MySQL server.");
    $db = mysql_select_db("Ph0enix_db") or die ("Unable to select requested database.");
    ?>[/code]

    I also had a website on tripod.lycos.co.uk and for that i just used "localhost" but sometimes you use "127.0.0.1" instead.

    So just try a few different things and make sure you havent made little mistakes.
  7. Ok, im a new to php so i dont know much.
    Im using this code below to get information from my table
    [code]
    <?php
    $db = mysql_connect("localhost","username","pass");
    mysql_select_db("database name",$db);

    $sql = "SELECT * FROM table name";
    $result = mysql_query($sql);
    while($row = mysql_fetch_array($result))
    {
       echo $row['field name'] . '<br>';
    }

    ?>
    [/code]

    The problem is that this code displays the information like
    1.bla
    2.bla
    3.bla

    How do i change it so it displays it
    3.bla
    2.bla
    1.bla

    So it will show the last item that was put into the table first?
    Please help! Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.