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 5 of 5
  1. #1
    New Coder
    Join Date
    Aug 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Help displaying mysql data

    Okay, I am making a script that is going to show someone's personal info using some cookies that are set when you log on. Using SELECT and a variable that is assigned the username cookie, I need to display their points. I just can't get it right! Could some one help me out on this? I'm so clueless

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You'll probably get better help if you pose more punctual questions + show us the code you already have.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    846
    Thanks
    15
    Thanked 10 Times in 10 Posts
    Well, you can also do it using SESSIONS... they will cancel out when you exit the browser though... giving it some extra security... you can still use cookies.

    PHP Code:
    $username=$_SESSION["username"];

    <?php 
    $sql 
    mysql_query("SELECT * FROM _____1_____ WHERE  ____2_____",$connection) or print mysql_error();
            
    $login_check mysql_num_rows($sql); 
            if(
    $login_check 0)
            { 
                while(
    $row mysql_fetch_array($sql))
                { 
                    foreach( 
    $row AS $key => $val )
                    { 
                        $
    $key stripslashes$val ); 
                    } 
                    
    ?>

    HTML GOES HERE

    <?php echo $row["points"]; ?>


    <?php } } ?>
    Now I'm going to explain.

    1. This is the table in your MySQL Database that you're selecting the data from.

    2. The row to select the info from... for example selecting user "dnirvine" points is
    PHP Code:
     username='dnirvine' 
    Usually this is a variable such as
    PHP Code:
     username='$username' 
    $username=$_SESSION["username"]; This takes the info from the session "username" and puts it into a variable for easy use.

    <?php echo $row["points"]; ?> This echos the row "points" from the database.


    Hope this helps.
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #4
    New Coder
    Join Date
    Aug 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks!

  • #5
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    846
    Thanks
    15
    Thanked 10 Times in 10 Posts
    After all the taking I was finally able to help someone!
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com


  •  

    Posting Permissions

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