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 3 of 3

Thread: PHP problems

  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP problems

    I'm a php newbie, so please do bear with me. I want to have a php file that lists all of hte contents on one of the rows on a sql table.

    I have a table with two fields, username, and password.

    I want a page that displays all the stuf funder username.

    I have this:

    Code:
    <?php
    
      $sql = "SELECT username FROM beta";
      $query = mysql_query($sql, $var);
    
        while($row = mysql_fetch_row($query)) {
      
        echo $row['0'].'<br />';
    
      }
    
    ?>
    It doesn't work. Can someone provide me with a better code, that actually works.

    Thanks.

    I posted this on the othe rforum too so I could get an answer.

  • #2
    Regular Coder Tyree's Avatar
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If I'm understanding correctly, you want to display all the usernames in your table.

    The query:
    PHP Code:
    $query "SELECT * FROM beta";
    $result mysql_query($query);

    while(
    $row mysql_fetch_row($result))
       {
      
        
    $entries[] = $row;

       } 
    To display it on the page:
    PHP Code:
    foreach ($entries AS $entry) {
     print 
    $entry['username'];


  • #3
    Regular Coder
    Join Date
    Aug 2006
    Location
    UK, London, Dartford
    Posts
    221
    Thanks
    3
    Thanked 14 Times in 14 Posts
    Posted to your post in MySQL Section....


  •  

    Posting Permissions

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