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
  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    myqsl database download of data to website page

    I'm trying to display data on a webpage that is relevant to that particular username. The only thing that would be completely unique for each row of data is the ID column.

    Currently, I'm able to display the data from each row but it displays all of the rows due to a while loop.

    while($rows=mysql_fetch_array($result)){
    ?>

    Then the table code echos the $rows amd variables.

    <?php
    // close while loop
    }
    ?>

    How do I get this to only display data that is relevant for that particular username?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,441
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    Change the SQL query. Which you didn't bother to show us, so I have no idea what it looks like.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Banned
    Join Date
    Mar 2013
    Posts
    139
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Quote Originally Posted by jp12 View Post

    How do I get this to only display data that is relevant for that particular username?
    If $result must contain data for more than 1 user, say for other purposes in your script, than you need an IF statement in your while loop that looks for the id of the user whose data you want to display.

    Otherwise it would be simpler to retrieve from the db just the record you need to display using something like

    select * from users where id=xxxxx where xxxxx is the user's id in the db.


  •  

    Posting Permissions

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