Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8

Thread: list

  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Posts
    153
    Thanks
    1
    Thanked 0 Times in 0 Posts

    list

    Im not that good at PHP, have a look at this and i think ul find it funny but i aint got a clue. How would i make it list all the usernames?


    <?php

    $sql = "SELECT * FROM ALS_signup";
    $result = mysql_query($sql, $conn) or die(mysql_error());
    while ($newArray = mysql_fetch_array($result)) {

    $username = $newArray['username'];

    echo" <select name='test'>
    <option>$username</option>
    </select>
    ";

    }

    ?>

  • #2
    New Coder
    Join Date
    Jul 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're missing the mysql_connect and database selection procedures.

  • #3
    Regular Coder
    Join Date
    Jul 2005
    Posts
    153
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I have that,

    I just need to know how to get the list menu working

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    assumin you have a field in your database called 'username' then your code should work as-is , whats the problem you are having ?
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    Regular Coder
    Join Date
    Jul 2005
    Posts
    153
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/****/public_html/members/messages.php on line 508

  • #6
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    so $conn is not valid , do other queries fail or just this one ?

    how do you connect to the database ? try just using
    $result = mysql_query($sql) ;//without the $conn
    if that fails show us your mysql_connect(); statement
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #7
    Regular Coder
    Join Date
    Sep 2005
    Location
    Liverpool
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    after you have sorted out the mysql problem you may want to redo things slightly:
    PHP Code:
    <?php    
    $sql 
    "SELECT * FROM ALS_signup";
    $result mysql_query($sql$conn) or die(mysql_error());
    echo 
    "<select name='test'>";
    while (
    $newArray mysql_fetch_array($result)) {
        
    $username $newArray['username'];
        echo
    " <option>$username</option>";
    }
    echo 
    "</select>";
    ?>
    otherwise you will be creating a select box for each username.
    my mind is on a permanent tangent

  • #8
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts


  •  

    Posting Permissions

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