Display info from table how?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Breana
    New Member
    • Aug 2007
    • 117

    Display info from table how?

    Ok, i am trying to make a page, where it shows all the members stats. "names"
    and i can get it to show 6, witch is how many members i have i want it to echo there names with a <br /> after each one...

    Heres what i got, but like i said it shows a number not the actual text "breana"
    [PHP]<?
    $sql = "select login from users where userid = $uid";
    $totalcount = mysql_num_rows( $result);
    ?>[/PHP]

    And it is displayed with:
    [PHP]<?php print("$totalco unt"); ?>[/PHP]

    Witch works much better i found out, then a page full of code lol.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Breana.

    As my signature states, the most exciting part of computer programming is getting a machine that does exactly what you tell it to do, to do what you want it to do.

    And right now, it's doing exactly what you're telling it to do.

    To output data from a MySQL table, you need to do something like this:
    [code=php]
    $sql = "select login from users where userid = $uid";
    $_res = mysql_query($sq l);

    while( $_row = mysql_fetch_ass oc($_res) )
    {
    echo $_row['login'], '<br />';
    }
    mysql_free_resu lt($_res);
    [/code]

    Comment

    • Breana
      New Member
      • Aug 2007
      • 117

      #3
      Hi that does work but i want it to display all id listed in the table.
      breana
      mike
      sara
      hillary
      hillary
      bitegs

      like that...

      I tried ur code it only shows my id "logged in id"
      ?

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Heya, Breana.

        Right now, you're only SELECTing the login for the User whose id is '$uid'.

        Comment

        • Breana
          New Member
          • Aug 2007
          • 117

          #5
          Lol i dident look at that yeah it will do that..
          I removed it works :)

          Got a quick question, what if i need more than the name.
          Like name, date, gender, email?

          Thanks.

          Comment

          • Breana
            New Member
            • Aug 2007
            • 117

            #6
            Thanx

            Update, NM i figured it out lol.

            [PHP]<?
            $sql = "select login, gender, points from users";
            $_res = mysql_query($sq l);
            while( $_row = mysql_fetch_ass oc($_res) )
            {
            echo '<p align="left">', $_row['login'], '&nbsp;&nbsp;&n bsp;', '<font color="#FF0000" >', $_row['gender'], '</font>', '&nbsp;&nbsp;&n bsp;', '<font color="#0000FF" >', $_row['points'], '</font>', '</p>', '<br />';
            }
            mysql_free_resu lt($_res);
            ?>[/PHP]

            Se i am learning :)
            Last edited by Breana; Aug 26 '07, 09:15 PM. Reason: Oops in text again.. + updating it

            Comment

            • pbmods
              Recognized Expert Expert
              • Apr 2007
              • 5821

              #7
              Heya, Breana.

              Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)

              Comment

              Working...