Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-28-2013, 08:53 PM   PM User | #1
jp12
New to the CF scene

 
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
jp12 is an unknown quantity at this point
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?
jp12 is offline   Reply With Quote
Old 03-28-2013, 09:30 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,054 Times in 4,023 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is online now   Reply With Quote
Old 03-29-2013, 03:07 AM   PM User | #3
knightCoder
Banned

 
Join Date: Mar 2013
Posts: 139
Thanks: 0
Thanked 9 Times in 9 Posts
knightCoder can only hope to improve
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.
knightCoder is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:34 AM.


Advertisement
Log in to turn off these ads.